Getting encryption state of a string
To know whether the string is encrypted, use IsECLStringEncrypted function.
The following example illustrates how to check whether the string is encrypted and handle wrong password input.
Example:
var
CompStr, DecompStr: string;
begin
ECLCompressAndEncryptString('test', CompStr, 'Password', ppmFastest);
if (IsECLStringEncrypted(CompStr)) then
begin
if (not ECLDecompressAndDecryptString(CompStr, DecompStr, 'Wrong Password')) then
ShowMessage('Decrypting with wrong password is failed!');
if (not ECLDecompressAndDecryptString(CompStr, DecompStr, 'Password')) then
ShowMessage('Decrypting with right password is failed!');
end
else
ECLDecompressAndDecryptString(CompStr, DecompStr);
ShowMessage('Decrypted string: '+DecompStr);
end;
|