![]() ![]() ![]() |
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
{ compress and encrypt a string }
ECLCompressAndEncryptString('test', CompStr, 'Password', ppmFastest);
{ is string encrypted }
if (IsECLStringEncrypted(CompStr)) then
begin
{ try to decompress and decrypt a string with a wrong password}
if (not ECLDecompressAndDecryptString(CompStr, DecompStr, 'Wrong Password')) then
ShowMessage('Decrypting with wrong password is failed!');
{ try to decompress and decrypt a string with right password}
if (not ECLDecompressAndDecryptString(CompStr, DecompStr, 'Password')) then
ShowMessage('Decrypting with right password is failed!');
end
else
{ string is not encrypted, simply decompress a string }
ECLDecompressAndDecryptString(CompStr, DecompStr);
{ show decompressed string }
ShowMessage('Decrypted string: '+DecompStr);
end;