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 memory buffer

 


 

With Easy Compression Library you can easily compress/encrypt and decompress/decrypt a data in memory buffer.

 

Compressing/encrypting a memory buffer.

To compress and encrypt a buffer you need to call ECLCompressAndEncryptBuffer function.

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

CompressionLevel specifies what compression algorithm and mode is used.

If the buffer data 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 memory buffer.

To decompress and decrypt a buffer you need to call ECLDecompressAndDecryptBuffer.

 

Also you may want to know whether the data in buffer is encrypted.

 

The following example illustrates how to compress and encrypt a data in buffer and then decompress and decrypt it.

Example:

var

SrcBuf, CompBuf, DecompBuf: PChar;

SrcSize, CompSize, DecompSize: integer;

s: String;

begin

{ source data }

s := 'test-test';

{ pointer to source data }

SrcBuf := PChar(s);

{ size of source data }

SrcSize := Length(s)+1;

{ compress and encrypt source buffer to destination buffer }

ECLCompressAndEncryptBuffer(SrcBuf, SrcSize, CompBuf, CompSize, 'Password', ppmFastest);

{ decompress and decrypt buffer }

ECLDecompressAndDecryptBuffer(CompBuf, CompSize, DecompBuf, DecompSize, 'Password');

{ display decompressed/decrypted data }

ShowMessage(DecompBuf);

end;

 

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