Encrypting a string
With Easy Compression Library you can easily encrypt and decrypt a string.
Encrypting a string.
To encrypt a string you need to call ECLCompressAndEncryptString function.
The Password parameter must be not blank.
Decrypting a string.
To decrypt a string you need to call ECLDecompressAndDecryptString.
Warning:
Set bHexFormat parameter of ECLCompressAndEncryptString to True if you plan to access encrypted string as null-terminated string (PChar). This is required if you store encrypted password to Registry for example.
By default encrypted string can contain some CHR(0) entrances and accessing the string with PChar() will not be correct.
Example:
var
EncryptStr, DecryptStr: string;
begin
ECLCompressAndEncryptString('test', EncryptStr, 'Password', ppmFastest);
ECLDecompressAndDecryptString(EncryptStr, DecryptStr, 'Password');
ShowMessage(DecryptStr);
end;
|