Delphi Database, Delphi Components from ComponentAce
Products Download Order Contact us
/img/help/home.gif /img/help/disprev.gif /img/help/next.gif

 

Compressing and encrypting a string

 


 

With Easy Compression Library you can easily compress/encrypt and decompress/decrypt a string.

 

Compressing/encrypting a string.

To compress and encrypt a string you need to call ECLCompressAndEncryptString function.

If the string should not be encrypted, the Password parameter is to be blank.

CompressionLevel specifies what compression algorithm and mode is used.

If the string should not be compressed, the CompressionLevel parameter is to be eclNone.

If you need to have data corruption verification code you should set bNoCRC parameter to False;

 

Decompressing/decrypting a string.

To decompress and decrypt a string you need to call ECLDecompressAndDecryptString.

 

Also you may want to know whether the string is encrypted.

 

Warning:

Set bHexFormat parameter of ECLCompressAndEncryptString to True if you plan to access the compressed / encrypted string as null-terminated string (PChar). This is required if you store encrypted password to Registry for example.

By default compressed / encrypted string can contain some CHR(0) entrances and accessing the string with PChar() will not be correct.

 

The following example illustrates how to compress and encrypt a string and then decompress and decrypt it.

Example:

var

CompStr, DecompStr: string;

begin

{ compress and encrypt a string }

ECLCompressAndEncryptString('test', CompStr, 'Password', ppmFastest);

{ decompress and decrypt a string }

ECLDecompressAndDecryptString(CompStr, DecompStr, 'Password');

{ show decompressed string }

ShowMessage(DecompStr);

end;

        © 2003 - 2024 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Dec 03, 2024