I'm a newbie on encrypting/decrypting routines. I'm trying to use Lockbox3, which I want migrate my app to, in order to decrypt a string encrypted by using DCPCrypt. Let's say I have this function to encrypt:
function TfrmMain.Encrypt(value: string): string;
var
CipherR : TDCP_rijndael;
m, sm, Key, IV: string;
Data: string;
begin
Key := PadWithZeros(m, KeySize);
IV := PadWithZeros(sm, BlockSize);
Data := PadWithZeros(value, BlockSize);
m := 'SOMEWORDSOMEWORD';
sm := 'WORDSOMEWORDSOME';
Key := PadWithZeros(m, KeySize);
IV := PadWithZeros(sm, BlockSize);
CipherR := TDCP_rijndael.Create(Self);
if Length(m) <= 16 then
CipherR.Init(Key[1], 128, @IV[1])
else if Length(m) <= 24 then
CipherR.Init(Key[1], 192, @IV[1])
else
CipherR.Init(Key[1], 256, @IV[1]);
CipherR.EncryptCBC(Data[1], Data[1], Length(Data));
CipherR.Free;
FillChar(Key[1], Length(Key), 0);
code := Base64EncodeStr(Data);
Result := code;
end;
I would like now to decrypt strings encrypted this way using Lockbox3, but I should use the values used in encrypt function as m and sm and I know how I can do it - if I can. I thought to use the sm value to set Codec1.Password but this doesn't work.
Any idea? Thanks to all for any advice.