Взял немного другую библиотеку в итоге, DPCrypt, шифрую и дешифрую как показано в хелпе:
Код
procedure TForm1.btnEncryptClick(Sender: TObject);
var
i: integer;
Cipher: TDCP_BlowFish; //TDCP_RC4 здесь заменил на TDCP_BlowFish
KeyStr: string;
begin
KeyStr:= '';
if InputQuery('Passphrase','Enter passphrase',KeyStr) then // get the passphrase
begin
Cipher:= TDCP_blowfish.Create(Self);
Cipher.InitStr(KeyStr,TDCP_sha1); // initialize the cipher with a hash of the passphrase
for i:= 0 to Memo1.Lines.Count-1 do // encrypt the contents of the memo
Memo1.Lines[i]:= Cipher.EncryptString(Memo1.Lines[i]);
Cipher.Burn;
Cipher.Free;
end;
end;
procedure TForm1.btnDecryptClick(Sender: TObject);
var
i: integer;
Cipher: TDCP_BlowFish; // //TDCP_RC4 здесь заменил на TDCP_BlowFish
KeyStr: string;
begin
KeyStr:= '';
if InputQuery('Passphrase','Enter passphrase',KeyStr) then // get the passphrase
begin
Cipher:= TDCP_blowfish.Create(Self);
Cipher.InitStr(KeyStr,TDCP_sha1); // initialize the cipher with a hash of the passphrase
for i:= 0 to Memo1.Lines.Count-1 do // decrypt the contents of the memo
Memo1.Lines[i]:= Cipher.DecryptString(Memo1.Lines[i]);
Cipher.Burn;
Cipher.Free;
end;
end;
Проблема в том, что при шифровании и дешифровке маленьких строк получаются кракозябры такого же размера, а при этом же процессе с длинными строками нормально дешифруется лишь вторая половина фразы. Перед расшифровкой строка передаётся по сети.