Re: Delphi encryption/PHP decryption and vice versa
- From: "Jan Doggen" <JanDoggenREMOVETHISSPAMBLOCKER@xxxxxxxxx>
- Date: Sat, 10 May 2008 16:38:09 +0200
I got it to work.
The Delphi sample in my original post comes from Dave Bartons website, but I
modified it a little and that was where the error is. His original code
works fine.
Jan
"Henrick Hellström" <henrick@xxxxxxxxxxxx> schreef in bericht
news:47fff31a@xxxxxxxxxxxxxxxxxxxxxxxxx
Jan Doggen wrote:
$rkey = 'simple24characterkey1234';
$riv = 'simple16byteiv12';
$data = 'jan@xxxxxxx';
$data = mcrypt_cbc(MCRYPT_RIJNDAEL_128,$rkey,$data,MCRYPT_ENCRYPT,$riv);
Now the bytes of the encrypted string are:
f8 a1 0d 75 58 2a 26 de f5 6b 84 bd 3a 45 b2 5e
Using StreamSec Tools 2.1 (which is equivalent to OpenStrSecII on
sourceforge.net in case you want an open source library), the following
code results yields the same output as the mcrypt PHP library:
uses
SecUtils, SsRijndael;
var
lKey: AnsiString;
lC: TCipher;
lS: AnsiString;
begin
lKey := 'simple24characterkey1234';
lS := 'jan@xxxxxxx'#0#0#0#0#0;
UniqueString(lS);
lC := TRijndael_CBC.Create(Pointer(lKey)^,Length(lKey),0);
try
lC.IVector := 'simple16byteiv12';
lC.Encrypt(Pointer(lS)^,Length(lS));
finally
lC.Free;
end;
ShowMessage(BinToHex(Pointer(lS)^,Length(lS)));
.
- Prev by Date: Re: Which is the best lightweight and high performance framework for writing a networked collaborative system?
- Next by Date: Re: TurboPower library NNTP newsgroups
- Previous by thread: Visual FoxPro ODBC and 64-bit
- Next by thread: MS Word 2003 like MDI component
- Index(es):