Custom radProgrammer fork. No anticipated logic changes to be implemented in this fork.
Recommended only for radProgrammer projects - others should use the parent fork instead.
Customizations:
tools/open-repo.bat: Standard simple utility to allow click-to-open repo functionality- Extended
.gitignore - Added
.gitattributes - Added .dproj file for VER370
- Configured release builds paths for DCP + Unit output directory to
$(BDSUSERDIR)\Imports\$(Platform) - Manually built Win32+Win64 release builds
- Default output path set to
.\$(Platform)\$(Config)if needing to debug
- Configured release builds paths for DCP + Unit output directory to
Comprehensive hashing library for Object Pascal
HashLib4Pascal is a comprehensive hashing library for Object Pascal, providing an easy-to-use interface for computing hashes, checksums, MACs, KDFs, and XOFs with support for state-based (incremental) hashing, released under the permissive MIT License.
- Features
- Available Algorithms
- Getting Started
- Quick Examples
- Running Tests
- Contributing
- Other Implementations
- Tip Jar
- License
- Branding
- Extensive hash coverage -- CRC (all standard variants from CRC3 to CRC64), non-cryptographic (Murmur, XXHash, SipHash, etc.), and cryptographic (SHA-2, SHA-3, Blake2, Blake3, and more)
- State-based (incremental) hashing -- feed data in chunks via
TransformBytes/TransformString, then finalize withTransformFinal - One-shot convenience --
ComputeString,ComputeBytes,ComputeFile,ComputeStreamfor single-call hashing - Password hashing / KDFs -- Argon2 (2i/2d/2id), Scrypt, PBKDF2-HMAC
- MACs -- HMAC (all supported hashes), KMAC (128/256), Blake2BMAC, Blake2SMAC
- Extendable output functions (XOFs) -- Shake, CShake, Blake2X, KMACXOF, Blake3XOF
- Cloneable state -- clone any hash instance mid-computation for parallel/divergent processing
- Cross-platform -- Delphi and FreePascal on Windows, Linux, macOS, and more
Non-Cryptographic Hash Functions
AP | BKDR | Bernstein | Bernstein1 | DEK | DJB | ELF | FNV | FNV1a | Jenkins3 | JS | Murmur2 | MurmurHash3_x86_32 | OneAtTime | PJW | Rotating | RS | SDBM | ShiftAndXor | SuperFast | XXHash32
FNV64 | FNV1a64 | Murmur2_64 | SipHash2_4 | XXHash64 | XXHash3
SipHash128_2_4 | MurmurHash3_x86_128 | MurmurHash3_x64_128 | XXHash128
Cryptographic Hash Functions
| Family | Variants |
|---|---|
| MD | MD2, MD4, MD5 |
| SHA-0 | SHA-0 |
| SHA-1 | SHA-1 |
| SHA-2 | 224, 256, 384, 512, 512-224, 512-256 |
| SHA-3 | 224, 256, 384, 512 |
| Keccak | 224, 256, 288, 384, 512 |
| Blake2B | 160, 256, 384, 512 |
| Blake2S | 128, 160, 224, 256 |
| Blake2BP | Blake2BP |
| Blake2SP | Blake2SP |
| Blake3 | Blake3 |
| GOST | 34.11-94, R 34.11-2012 (256, 512) |
| Grindahl | 256, 512 |
| HAS160 | HAS160 |
| RIPEMD | 128, 160, 256, 320 |
| Tiger | 128, 160, 192 (Rounds 3, 4, 5) |
| Tiger2 | 128, 160, 192 (Rounds 3, 4, 5) |
| Snefru | 128, 256 |
| Haval | 128, 160, 192, 224, 256 (Rounds 3, 4, 5) |
| Panama | Panama |
| RadioGatun | RadioGatun32, RadioGatun64 |
| WhirlPool | WhirlPool |
MACs
HMAC (all supported hashes) | KMAC (128, 256) | Blake2BMAC | Blake2SMAC
XOF (Extendable Output Functions)
Shake (128, 256) | CShake (128, 256) | Blake2XS | Blake2XB | KMAC128XOF | KMAC256XOF | Blake3XOF
| Compiler | Minimum Version |
|---|---|
| Delphi | 2010 or later |
| FreePascal | 3.2.2 or later |
- Open and install the package:
HashLib/src/Packages/Delphi/HashLib4PascalPackage.dpk - Add the
HashLib/srcsubdirectories to your project's search path.
- Open and install the package:
HashLib/src/Packages/FPC/HashLib4PascalPackage.lpk
uses
SysUtils, HlpHashFactory;
var
LHash: String;
begin
LHash := THashFactory.TCrypto.CreateSHA2_256()
.ComputeString('Hello HashLib4Pascal', TEncoding.UTF8)
.ToString();
WriteLn(LHash);
end;uses
SysUtils, HlpIHash, HlpHashFactory;
var
LHashInstance: IHash;
begin
LHashInstance := THashFactory.TCrypto.CreateBlake2B_256();
LHashInstance.Initialize();
LHashInstance.TransformString('chunk one', TEncoding.UTF8);
LHashInstance.TransformString('chunk two', TEncoding.UTF8);
LHashInstance.TransformString('chunk three', TEncoding.UTF8);
WriteLn(LHashInstance.TransformFinal().ToString());
end;uses
SysUtils, HlpIHashInfo, HlpHashFactory, HlpConverters;
var
LHMAC: IHMAC;
begin
LHMAC := THashFactory.THMAC.CreateHMAC(
THashFactory.TCrypto.CreateSHA2_256(),
TConverters.ConvertStringToBytes('secret key', TEncoding.UTF8));
WriteLn(LHMAC.ComputeString('message', TEncoding.UTF8).ToString());
end;uses
SysUtils, HlpHashFactory, HlpConverters;
var
LDerivedKey: TBytes;
begin
LDerivedKey := TKDF.TPBKDF_Scrypt.CreatePBKDF_Scrypt(
TConverters.ConvertStringToBytes('password', TEncoding.UTF8),
TConverters.ConvertStringToBytes('salt', TEncoding.UTF8),
1024, 8, 1)
.GetBytes(32);
WriteLn(TConverters.ConvertBytesToHexString(LDerivedKey));
end;Tests use DUnit (Delphi) and FPCUnit (FreePascal).
- Delphi: Open
HashLib.Tests/Delphi.Tests/HashLib.Tests.dprin the IDE and run. - FreePascal / Lazarus: Open
HashLib.Tests/FreePascal.Tests/HashLib.Tests.lpiin the IDE and run.
Contributions are welcome. Please open an issue for bug reports or feature requests, and submit pull requests.
If you want implementations in other languages, you can check out these:
- HashLib4CPP by Mbadiwe Nnaemeka Ronald
If you find this library useful and would like to support its continued development, tips are greatly appreciated! 🙏
HashLib4Pascal is released under the MIT License.