TAESEncryption error on decrypt

I can successfully encrypt and save text to a disk file in Windows.

But when decrypting I get an error, what am I doing wrong?

Here is my code:

procedure TfrmSalaryInifil.ButtonCryptClick(Sender: TObject);
var
s : string;
SL: TStringList;
begin

s:='';
s:=trim(txtserver.text);
s:=kryptere.Encrypt(s);

SL := TStringList.Create;
try
SL.Text := s;
SL.SaveToFile(aCatalogue+'\Salary.Ini');
finally
SL.Free;
end;

end;

procedure TfrmSalaryInifil.ButtonDecryptClick(Sender: TObject);
var
s : string;
begin
s:=kryptere.Decrypt(aCatalogue+'\Salary.Ini');
end;

Snap1

SaveToFile may have converted some characters. It is better to save with FileWrite. Check that the cryptogram length is a multiple of 16 bytes.

Hi

I know zero about cryptograpy, that is why I use this library :slightly_smiling_face:

What is a "multiple of 16 bytes? Do you have a sample on how to save using FileWrite.

Kind regards, Ole

The filesize shall be a multiple of 16.
To save the encrypted data, you can try something like that:

  FileName := 'YourFilePath';
  if FileExists(FileName) = false then begin
    f := FileCreate(FileName);
    FileClose(f);
  end;

  f := FileOpen(FileName, fmOpenWrite);
  SetLength(Buffer, Length(s));
  for I := 0 to Length(s) - 1 do
    Buffer[I] := byte(s[I + 1]);
  FileWrite(f, Buffer, 0, Length(s));
  FileClose(f);
  SetLength(Buffer, 0);