Unit PXL.Data

DescriptionUsesClasses, Interfaces, Objects and RecordsFunctions and ProceduresTypesConstantsVariables

Description

Utility routines for working with binary data including compression, encryption and checksum calculation.

Overview

Classes, Interfaces, Objects and Records

Name Description
record TCipherBlock Initialization block used for XTEA cipher.
record TCipherKey Security password used for XTEA cipher.
record TMD5Checksum MD5 checksum value.

Functions and Procedures

function Base64Binary(const Source: TBase64String; const Dest: Pointer): Integer;
function Base64String(const Source: Pointer; const SourceSize: Integer): TBase64String;
function ChecksumCRC32(const Source: Pointer; const SourceSize: Cardinal): Cardinal; inline;
function ChecksumMD5(const Source: Pointer; const SourceSize: Cardinal): TMD5Checksum;
function CompressData(const Source, Dest: Pointer; const SourceSize, MaxDestSize: Cardinal; const Compression: TCompressionLevel = TCompressionLevel.Default): Cardinal;
function DecompressData(const Source, Dest: Pointer; const SourceSize, MaxDestSize: Cardinal): Cardinal;
procedure DecryptData(const Source, Dest: Pointer; const SourceSize: Integer; const InitVector: TCipherBlock; const Key: TCipherKey);
procedure EncryptData(const Source, Dest: Pointer; const SourceSize: Integer; const InitVector: TCipherBlock; const Key: TCipherKey);

Types

PCipherBlock = ˆTCipherBlock;
PCipherKey = ˆTCipherKey;
PMD5Checksum = ˆTMD5Checksum;
TBase64String = AnsiString ;
TCompressionLevel = (...);

Description

Functions and Procedures

function Base64Binary(const Source: TBase64String; const Dest: Pointer): Integer;

Decodes the base-64 readable text back into the binary format.

function Base64String(const Source: Pointer; const SourceSize: Integer): TBase64String;

Encodes the binary source into base-64 readable text. This effectively increases the size by 4/3 (rounded up). If the source is not divisible by 3, it will be padded with zeros.

function ChecksumCRC32(const Source: Pointer; const SourceSize: Cardinal): Cardinal; inline;

Calculates CRC32 checksum from the specified data. This checkum can be used in integrity tests to verify that the data has not been modified.

function ChecksumMD5(const Source: Pointer; const SourceSize: Cardinal): TMD5Checksum;

Calculates and returns 128-bit MD5 checksum of the given data block. This checksum can be used as a signature to verify that the data has not been altered in any way.

function CompressData(const Source, Dest: Pointer; const SourceSize, MaxDestSize: Cardinal; const Compression: TCompressionLevel = TCompressionLevel.Default): Cardinal;

Compresses data block from the source buffer to destination buffer. The memory for both buffers must be allocated. MaxDestSize can be used to specify the maximum data length that can be saved at the destination buffer to prevent overflow.

function DecompressData(const Source, Dest: Pointer; const SourceSize, MaxDestSize: Cardinal): Cardinal;

Decompresses data block from the source buffer to destination buffer. The memory for both buffers must be allocated. MaxDestSize can be used to specify the maximum data length that can be saved at the destination buffer to prevent overflow.

procedure DecryptData(const Source, Dest: Pointer; const SourceSize: Integer; const InitVector: TCipherBlock; const Key: TCipherKey);

Decrypts data using 128-bit XTEA cipher in CBC chaining mode and residual block termination (in case the data buffer is not multiple of 8 bytes).

procedure EncryptData(const Source, Dest: Pointer; const SourceSize: Integer; const InitVector: TCipherBlock; const Key: TCipherKey);

Encrypts data using 128-bit XTEA cipher in CBC chaining mode and residual block termination (in case the data buffer is not multiple of 8 bytes).

Types

PCipherBlock = ˆTCipherBlock;

Pointer to TCipherBlock.

PCipherKey = ˆTCipherKey;

Pointer to TCipherKey.

PMD5Checksum = ˆTMD5Checksum;

Pointer to TMD5Checksum.

TBase64String = AnsiString ;

Standard string type used for base-64 encoding.

TCompressionLevel = (...);

The level used for data compression.

Values
  • Default: Default compression ratio and performance.
  • BestSpeed: Optimize for performance at cost of compression ratio.
  • BestCompression: Optimize for better compression ratio at cost of performance.

Copyright © 2000 - 2017 Yuriy Kotsarenko. Help files generated by PasDoc.