SPECK Decrypt troubles between V4 and V5

Hi,

When even using the demo, I can’t decrypt a string crypted with speck under V4.

And even you use only the demo, you can’t decrypt a string you have just crypted !

Thanks to have a look….

Hi,

Please send me some code with what you want to to. Some Speck modes no longer exist in V5.

bernard@tmssoftware.com

Here is a generic fix fir v4 to v5 compatibility.

procedure TMainForm.FixBtnClick(Sender: TObject);
var
MySpeck: TSPECKEncryption;
s: string;
conv: TConvert;

begin
MySpeck := TSPECKEncryption.Create;
conv := TConvert.Create(hexa);
try
MySpeck.Comp := true; // ENSURES 4.x COMPATIBILITY - SET TO FALSE FOR FULL 5.x version
MySpeck.InputFormat := raw;
MySpeck.IVMode := rand;
MySpeck.Key := '0123456789012345';
MySpeck.Unicode := yesUni;
s := 'CCFE691BB9F52573598CFBCCD822D39A85C6B54F5ECE6C4D';

conv := TConvert.Create(hexa);
s := Conv.FormatToChar(s);
MySpeck.OutputFormat := raw;
s := MySpeck.Decrypt(s);
MainMemo.Lines.Add(s);

finally
MySpeck.Free;
end;

MySpeck := TSPECKEncryption.Create;
conv := TConvert.Create(hexa);
try
MySpeck.Comp := false;
MySpeck.InputFormat := raw;
MySpeck.IVMode := rand;
MySpeck.Key := '0123456789012345';
MySpeck.Unicode := yesUni;
s := MySpeck.Encrypt(s);
MainMemo.Lines.Add(s);

s := Conv.FormatToChar(s);
MySpeck.OutputFormat := raw;
s := MySpeck.Decrypt(s);
MainMemo.Lines.Add(s);

finally
Conv.Free;
MySpeck.Free;
end;
end;

Once previously encrypted data has been recovered, only encrypt it with Speck v5.

bernard