Encoding

Encoding & Hashing


EDigest

type EDigest = enum(MD4, MD5, SHA1, SHA256, SHA512, WHIRLPOOL);

Note

This enum is scoped, so must be used like EDigest.SHA512


EBaseEncoding

type EBaseEncoding = enum(b64URL, b64, b32, b32Hex, b16);

Note

This enum is scoped, so must be used like EBaseEncoding.b64


DigestString

function DigestString(Algo: EDigest; S: String): String;

Cryptographic digest (lowercase hex) of a string.


DigestFile

function DigestFile(Algo: EDigest; FileName: String): String;

Cryptographic digest (lowercase hex) of a file’s contents.


DigestData

function DigestData(Algo: EDigest; Data: Pointer; Len: Int32): String;

Cryptographic digest (lowercase hex) of a raw buffer.


CrcString

function CrcString(S: String): UInt32;

CRC32 checksum of a string.


CrcFile

function CrcFile(FileName: String): UInt32;

CRC32 checksum of a file’s contents.


CrcData

function CrcData(Data: Pointer; Len: Int32): UInt32;

CRC32 checksum of a raw buffer.


HashString

function HashString(S: String; Seed: UInt32 = 0): UInt32;

Fast non-cryptographic 32-bit hash (xxHash32) of a string. https://xxhash.com/


HashFile

function HashFile(FileName: String; Seed: UInt32 = 0): UInt32;

Fast non-cryptographic 32-bit hash (xxHash32) of a file’s contents.


HashData

function HashData(Data: Pointer; Len: Int32; Seed: UInt32 = 0): UInt32;

Fast non-cryptographic 32-bit hash (xxHash32) of a raw buffer.


BaseEncode

function BaseEncode(Encoding: EBaseEncoding; const Data: String): String;

BaseDecode

function BaseDecode(Encoding: EBaseEncoding; const Data: String): String;

ECompressAlgo

type ECompressAlgo = enum(ZLIB, SYNLZ, GZ, BZIP2, LZ4, LZMA);

Note

This enum is scoped, so must be used like ECompressAlgo.ZLIB


CompressData

procedure CompressData(Algo: ECompressAlgo; InData: Pointer; InSize: Int64; out OutData: Pointer; out OutSize: Int64; Truncate: Boolean = True);

DecompressData

procedure DecompressData(Algo: ECompressAlgo; InData: Pointer; InSize: Int64; out OutData: Pointer; out OutSize: Int64; Truncate: Boolean = True);

CompressBytes

function CompressBytes(Algo: ECompressAlgo; Bytes: TByteArray): TByteArray;

DecompressBytes

function DecompressBytes(Algo: ECompressAlgo; Bytes: TByteArray): TByteArray;

CompressString

function CompressString(Algo: ECompressAlgo; Encoding: EBaseEncoding; Str: String): String;

DecompressString

function DecompressString(Algo: ESimbaCompressAlgo; Encoding: EBaseEncoding; Str: String): String;

HOTPCalculateToken

function HOTPCalculateToken(const Secret: String; const Counter: Integer): Integer;
function TOTPCalculateToken(const Secret: String): Integer;

HOTP and TOTP One-time password algorithms. Compatible with Google Authenticator.