Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Delphi PHP und Blowfish (https://www.delphipraxis.net/184296-delphi-php-und-blowfish.html)

greenmile 16. Mär 2015 10:15

Delphi PHP und Blowfish
 
Hallo,

ich muss etwas in Delphi verschlüsseln und mit PHP wieder entschlüsseln. Hierfür nutze ich DEC 5.2, allerdings peile ich das nicht so recht. Vielleicht könnte mir jemand auf die Schnelle sagen warum folgendes nicht läuft? Das wäre super ... vielen Dank. Ich möchte einfach nur "quick and dirty" etwas auf die Schnelle halbwegs (!) sicher verschlüsseln.

Code:
function encryptBlowfisch(Key, Source: string): String;
  var IV: string;
begin
  IV := '12345678';
  with DECCipher.TCipher_Blowfish.Create do
   try
     Mode := cmCBCx;
     Init(Key,IV);
     Result := EncodeBinary(Source, TFormat_HEX);
   finally
     Free;
   end;
end;

function decryptBlowfisch(Key, Source: string): String;
  var IV: string;
begin
  IV := '12345678';
  with DECCipher.TCipher_Blowfish.Create do
   try
     Mode := cmCBCx;
     Init(Key,IV);
     Result := DecodeBinary(Source, TFormat_HEX);
   finally
     Free;
   end;
end;
Code:
 $decrypted_data = mcrypt_cfb (MCRYPT_BLOWFISH, $key, $input, MCRYPT_ENCRYPT, '12345678');

mkinzler 16. Mär 2015 10:22

AW: Delphi PHP und Blowfish
 
Was geht nicht?
Kommt ein Fehler?
Kommt was falsches raus?

greenmile 16. Mär 2015 10:23

AW: Delphi PHP und Blowfish
 
Wenn ich das Ergebnis von "decryptBlowfisch" der PHP als $Input gebe, kommt alles raus, aber nicht das richtige.

mkinzler 16. Mär 2015 10:25

AW: Delphi PHP und Blowfish
 
Häh?

greenmile 16. Mär 2015 10:29

AW: Delphi PHP und Blowfish
 
Also, bei Delphi kommt folgendes raus:

Code:
  encryptBlowfisch('schluessel','Hallo Welt');
  // Ergibt 4AB79BC001D8CA706467
Unter PHP

Code:
 $key = 'schluessel';
 $input = '4AB79BC001D8CA706467';
 $decrypted_data = mcrypt_cfb (MCRYPT_BLOWFISH, $key, $input, MCRYPT_DECRYPT, '12345678');
  // Ergibt zNZqXeQEH4s+lXFX6F6buKINKKI=, aber nicht "Hallo Welt"

mkinzler 16. Mär 2015 10:34

AW: Delphi PHP und Blowfish
 
Wahrscheinlich verwendet DEC einen andere initialization vector

greenmile 16. Mär 2015 10:38

AW: Delphi PHP und Blowfish
 
Wird der nicht so übergeben?

Code:
  IV := '12345678';
  Init(Key,IV);

CCRDude 16. Mär 2015 10:40

AW: Delphi PHP und Blowfish
 
In DEC verwendest Du Cipher Block Chaining (CBC), in PHP Cipher Feedback (CFB). Verwende doch mal den gleichen Modus ;)

himitsu 16. Mär 2015 10:40

AW: Delphi PHP und Blowfish
 
DecodeBinary ... Unicode?

Was kommt bei MCRYPT_DECRYPT im PHP raus?
PS: http://php.net/manual/en/function.mcrypt-cfb.php -> Warning

greenmile 16. Mär 2015 10:44

AW: Delphi PHP und Blowfish
 
Ruft intern "Encode" auf. Ich kann doch nix anderes aufrufen.


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:51 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz