I'd like to migrate my old crypto functions from lockbox2 to lockbox3 on delphi XE6. Before to do that I've made a code (CipherComp.dpr) to compare the output, since the setup have changed.
I'm using AES-ECB (to avoid IV) 256 bits, key: '1234567890', text: 'a secret word'
Using TPLB2 I initialize like
FAES : TLbRijndael;
FAES := TLbRijndael.Create(nil);
FAES.CipherMode := cmECB; // cmECB (default), cmCBC
FAES.KeySize := ks256; // ks128, ks192
FAES.SetKey('1234567890'); // set the password here
and encrypt using:
Result := FAES.EncryptString(pString);
on the other hand on TPLB3 changes like this
FCodec: TCodec;
FCryptoLib: TCryptographicLibrary;
FCodec := TCodec.Create(nil);
FCryptoLib := TCryptographicLibrary.Create(nil);
FCodec.CryptoLibrary := FCryptoLib;
FCodec.StreamCipherId := uTPLb_Constants.BlockCipher_ProgId;
FCodec.BlockCipherId := 'native.AES-256';
FCodec.ChainModeId := uTPLb_Constants.ECB_ProgId;
FCodec.Password := '1234567890';
and encrypt
FCodec.EncryptAnsiString(pString, Result);
but the output mismatch when cipher the same text.
a secret word qD9+fF1EqdQH8C3TrEaLQg==
a secret word 1bUXLgXwob1cL6O27HMViw==
I'm doing something wrong but I can figure out what.
Any hint?
Thanks in advance.