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
s := 'test-test';
SrcBuf := PChar(s);
SrcSize := Length(s)+1;
ECLCompressAndEncryptBuffer(SrcBuf, SrcSize, CompBuf, CompSize, 'Password', ppmFastest);
ECLDecompressAndDecryptBuffer(CompBuf, CompSize, DecompBuf, DecompSize, 'Password');
ShowMessage(DecompBuf);
end;
|