Skip to content

Commit b7f9eeb

Browse files
committed
update README and inc file
1 parent 92b1364 commit b7f9eeb

2 files changed

Lines changed: 179 additions & 96 deletions

File tree

HashLib/src/Include/HashLibFPC.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
1313

1414
{$IFDEF FPC}
15-
// FPC 3.0.0 and Above
16-
{$IF FPC_FULLVERSION < 30000}
17-
{$MESSAGE ERROR 'This Library requires FreePascal 3.0.0 or higher.'}
15+
// FPC 3.2.2 and Above
16+
{$IF FPC_FULLVERSION < 30202}
17+
{$MESSAGE ERROR 'This Library requires FreePascal 3.2.2 or higher.'}
1818
{$IFEND}
1919

2020
{$IFDEF ENDIAN_BIG}

README.md

Lines changed: 176 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,236 @@
1-
HashLib4Pascal: Hashing for Modern Object Pascal [![License](http://img.shields.io/badge/license-MIT-green.svg)](https://github.com/Xor-el/HashLib4Pascal/blob/master/LICENSE)
2-
========================================
1+
# HashLib4Pascal
32

4-
``HashLib4Pascal`` is an Object Pascal hashing library released under the permissive [MIT License](https://github.com/Xor-el/HashLib4Pascal/blob/master/LICENSE) which provides an easy to use interface for computing hashes and checksums of data. It also supports state based (incremental) hashing.
3+
[![Build Status](https://github.com/Xor-el/HashLib4Pascal/actions/workflows/make.yml/badge.svg)](https://github.com/Xor-el/HashLib4Pascal/actions/workflows/make.yml)
4+
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Xor-el/HashLib4Pascal/blob/master/LICENSE)
5+
[![Delphi](https://img.shields.io/badge/Delphi-2010%2B-red.svg)](https://www.embarcadero.com/products/delphi)
6+
[![FreePascal](https://img.shields.io/badge/FreePascal-3.2.2%2B-blue.svg)](https://www.freepascal.org/)
57

6-
``HashLib4Pascal's`` goal is to be the best option for hashing in Object Pascal by offering various hashing primitives via an easy to use API to Object Pascal developers.
8+
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](LICENSE).
79

8-
Development is coordinated on [GitHub](https://github.com/Xor-el/HashLib4Pascal) and contributions are welcome. If you need help, please open an issue [here](https://github.com/Xor-el/HashLib4Pascal/issues).
10+
## Table of Contents
911

12+
- [Features](#features)
13+
- [Available Algorithms](#available-algorithms)
14+
- [Getting Started](#getting-started)
15+
- [Quick Examples](#quick-examples)
16+
- [Running Tests](#running-tests)
17+
- [Contributing](#contributing)
18+
- [Other Implementations](#other-implementations)
19+
- [Tip Jar](#tip-jar)
20+
- [License](#license)
1021

11-
**Build Status**
12-
[![Build Status](https://github.com/Xor-el/HashLib4Pascal/actions/workflows/make.yml/badge.svg)](https://github.com/Xor-el/HashLib4Pascal/actions/workflows/make.yml)
22+
## Features
23+
24+
- **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)
25+
- **State-based (incremental) hashing** -- feed data in chunks via `TransformBytes` / `TransformString`, then finalize with `TransformFinal`
26+
- **One-shot convenience** -- `ComputeString`, `ComputeBytes`, `ComputeFile`, `ComputeStream` for single-call hashing
27+
- **Password hashing / KDFs** -- Argon2 (2i/2d/2id), Scrypt, PBKDF2-HMAC
28+
- **MACs** -- HMAC (all supported hashes), KMAC (128/256), Blake2BMAC, Blake2SMAC
29+
- **Extendable output functions (XOFs)** -- Shake, CShake, Blake2X, KMACXOF, Blake3XOF
30+
- **Cloneable state** -- clone any hash instance mid-computation for parallel/divergent processing
31+
- **Cross-platform** -- Delphi and FreePascal on Windows, Linux, macOS, and more
32+
33+
## Available Algorithms
34+
35+
<details>
36+
<summary>Checksums</summary>
37+
38+
#### CRC
39+
`All CRC variants from CRC3 to CRC64`
40+
41+
#### Other
42+
`Adler32`
43+
44+
</details>
45+
46+
<details>
47+
<summary>Non-Cryptographic Hash Functions</summary>
1348

14-
Available Algorithms
15-
----------------------------------------
49+
#### 32-bit
50+
`AP` | `BKDR` | `Bernstein` | `Bernstein1` | `DEK` | `DJB` | `ELF` | `FNV` | `FNV1a` | `Jenkins3` | `JS` | `Murmur2` | `MurmurHash3_x86_32` | `OneAtTime` | `PJW` | `Rotating` | `RS` | `SDBM` | `ShiftAndXor` | `SuperFast` | `XXHash32`
1651

17-
### Hashes
18-
----------------------------------------
19-
##### Cyclic Redundancy Checks
52+
#### 64-bit
53+
`FNV64` | `FNV1a64` | `Murmur2_64` | `SipHash2_4` | `XXHash64`
2054

21-
* `All CRC Variants from CRC3 to CRC64`
55+
#### 128-bit
56+
`SipHash128_2_4` | `MurmurHash3_x86_128` | `MurmurHash3_x64_128`
2257

23-
##### Checksums
58+
</details>
2459

25-
* `Adler32`
60+
<details>
61+
<summary>Cryptographic Hash Functions</summary>
2662

27-
##### Non-Cryptographic Hash Functions
28-
----------------------------------------
63+
| Family | Variants |
64+
|---|---|
65+
| MD | MD2, MD4, MD5 |
66+
| SHA-0 | SHA-0 |
67+
| SHA-1 | SHA-1 |
68+
| SHA-2 | 224, 256, 384, 512, 512-224, 512-256 |
69+
| SHA-3 | 224, 256, 384, 512 |
70+
| Keccak | 224, 256, 288, 384, 512 |
71+
| Blake2B | 160, 256, 384, 512 |
72+
| Blake2S | 128, 160, 224, 256 |
73+
| Blake2BP | Blake2BP |
74+
| Blake2SP | Blake2SP |
75+
| Blake3 | Blake3 |
76+
| GOST | 34.11-94, R 34.11-2012 (256, 512) |
77+
| Grindahl | 256, 512 |
78+
| HAS160 | HAS160 |
79+
| RIPEMD | 128, 160, 256, 320 |
80+
| Tiger | 128, 160, 192 (Rounds 3, 4, 5) |
81+
| Tiger2 | 128, 160, 192 (Rounds 3, 4, 5) |
82+
| Snefru | 128, 256 |
83+
| Haval | 128, 160, 192, 224, 256 (Rounds 3, 4, 5) |
84+
| Panama | Panama |
85+
| RadioGatun | RadioGatun32, RadioGatun64 |
86+
| WhirlPool | WhirlPool |
2987

30-
###### 32 bit hashes
88+
</details>
3189

32-
* `AP` `BKDR` `Bernstein` `Bernstein1` `DEK` `DJB` `ELF` `FNV`
90+
<details>
91+
<summary>Key Derivation Functions</summary>
3392

34-
* `FNV1a` `JS` `Jenkins3` `Murmur2` `MurmurHash3_x86_32` `OneAtTime`
93+
#### Password Hashing
94+
`PBKDF2-HMAC` | `Argon2 (2i, 2d, 2id)` | `Scrypt`
3595

36-
* `PJW` `RS` `Rotating` `SDBM` `ShiftAndXor` `SuperFast` `XXHash32`
96+
</details>
3797

38-
###### 64 bit hashes
98+
<details>
99+
<summary>MACs</summary>
39100

40-
* `FNV64` `FNV1a64` `Murmur2_64` `SipHash2_4` `XXHash64`
101+
`HMAC (all supported hashes)` | `KMAC (128, 256)` | `Blake2BMAC` | `Blake2SMAC`
41102

42-
###### 128 bit hashes
103+
</details>
43104

44-
* `MurmurHash3_x86_128` `MurmurHash3_x64_128`
105+
<details>
106+
<summary>XOF (Extendable Output Functions)</summary>
45107

46-
##### Cryptographic Hash Functions
47-
----------------------------------------
108+
`Shake (128, 256)` | `CShake (128, 256)` | `Blake2XS` | `Blake2XB` | `KMAC128XOF` | `KMAC256XOF` | `Blake3XOF`
48109

49-
* `MD2`
110+
</details>
50111

51-
* `MD4`
112+
## Getting Started
52113

53-
* `MD5`
114+
### Prerequisites
54115

55-
* `SHA-0`
116+
| Compiler | Minimum Version |
117+
|---|---|
118+
| Delphi | 2010 or later |
119+
| FreePascal | 3.2.2 or later |
56120

57-
* `SHA-1`
121+
### Installation
58122

59-
* `SHA-2 (224, 256, 384, 512, 512-224, 512-256)`
123+
#### Delphi
60124

61-
* `GOST 34.11-94`
125+
1. Open and install the package: `HashLib/src/Packages/Delphi/HashLib4PascalPackage.dpk`
126+
2. Add the `HashLib/src` subdirectories to your project's search path.
62127

63-
* `GOST R 34.11-2012 (AKA Streebog) (256, 512)`
64-
65-
* `Grindahl (256, 512)`
66-
67-
* `Has160`
128+
#### FreePascal / Lazarus
68129

69-
* `RIPEMD (128, 160, 256, 256, 320)`
130+
1. Open and install the package: `HashLib/src/Packages/FPC/HashLib4PascalPackage.lpk`
70131

71-
* `Tiger (128, 160, 192 (Rounds 3, 4, 5))`
132+
## Quick Examples
72133

73-
* `Tiger2 (128, 160, 192 (Rounds 3, 4, 5))`
74-
75-
* `Snefru (128, 256)`
76-
77-
* `Haval (128, 160, 192, 224, 256 (Rounds 3, 4, 5))`
78-
79-
* `Panama`
80-
81-
* `RadioGatun (RadioGatun32, RadioGatun64)`
134+
### SHA-256 Hash
82135

83-
* `WhirlPool`
136+
```pascal
137+
uses
138+
SysUtils, HlpHashFactory;
84139
85-
* `Blake2B (160, 256, 384, 512)`
86-
87-
* `Blake2S (128, 160, 224, 256)`
140+
var
141+
LHash: String;
142+
begin
143+
LHash := THashFactory.TCrypto.CreateSHA2_256()
144+
.ComputeString('Hello HashLib4Pascal', TEncoding.UTF8)
145+
.ToString();
88146
89-
* `SHA-3 (224, 256, 384, 512)`
90-
91-
* `Keccak (224, 256, 288, 384, 512)`
147+
WriteLn(LHash);
148+
end;
149+
```
92150

93-
* `Blake2BP`
151+
### Incremental (Streaming) Hash
94152

95-
* `Blake2SP`
153+
```pascal
154+
uses
155+
SysUtils, HlpIHash, HlpHashFactory;
96156
97-
* `Blake3`
157+
var
158+
LHashInstance: IHash;
159+
begin
160+
LHashInstance := THashFactory.TCrypto.CreateBlake2B_256();
161+
LHashInstance.Initialize();
98162
99-
### Key Derivation Functions
100-
----------------------------------------
163+
LHashInstance.TransformString('chunk one', TEncoding.UTF8);
164+
LHashInstance.TransformString('chunk two', TEncoding.UTF8);
165+
LHashInstance.TransformString('chunk three', TEncoding.UTF8);
101166
102-
###### Password Hashing Schemes (Password Based Key Derivation Functions)
167+
WriteLn(LHashInstance.TransformFinal().ToString());
168+
end;
169+
```
103170

104-
----------------------------------------
171+
### HMAC
105172

106-
* `PBKDF2`
107-
108-
* `Argon2 (2i, 2d and 2id variants)`
173+
```pascal
174+
uses
175+
SysUtils, HlpIHashInfo, HlpHashFactory, HlpConverters;
109176
110-
* `Scrypt`
177+
var
178+
LHMAC: IHMAC;
179+
begin
180+
LHMAC := THashFactory.THMAC.CreateHMAC(
181+
THashFactory.TCrypto.CreateSHA2_256(),
182+
TConverters.ConvertStringToBytes('secret key', TEncoding.UTF8));
111183
112-
### MAC
113-
----------------------------------------
184+
WriteLn(LHMAC.ComputeString('message', TEncoding.UTF8).ToString());
185+
end;
186+
```
114187

115-
* `HMAC (all supported hashes)`
188+
### Scrypt KDF
116189

117-
* `KMAC (KMAC128, KMAC256)`
190+
```pascal
191+
uses
192+
SysUtils, HlpIHashInfo, HlpHashFactory, HlpConverters;
118193
119-
* `Blake2MAC (Blake2BMAC, Blake2SMAC)`
194+
var
195+
LDerivedKey: TBytes;
196+
begin
197+
LDerivedKey := TKDF.TPBKDF_Scrypt.CreatePBKDF_Scrypt(
198+
TConverters.ConvertStringToBytes('password', TEncoding.UTF8),
199+
TConverters.ConvertStringToBytes('salt', TEncoding.UTF8),
200+
1024, 8, 1)
201+
.GetBytes(32);
120202
121-
### XOF (Extendable Output Function)
122-
----------------------------------------
203+
WriteLn(TConverters.ConvertBytesToHexString(LDerivedKey));
204+
end;
205+
```
123206

124-
* `Shake (Shake-128, Shake-256)`
207+
## Running Tests
125208

126-
* `CShake (CShake-128, CShake-256)`
209+
Tests use **DUnit** (Delphi) and **FPCUnit** (FreePascal).
127210

128-
* `Blake2X (Blake2XS, Blake2XB)`
211+
- **Delphi:** Open `HashLib.Tests/Delphi.Tests/HashLib.Tests.dpr` in the IDE and run.
212+
- **FreePascal / Lazarus:** Open `HashLib.Tests/FreePascal.Tests/HashLib.Tests.lpi` in the IDE and run.
129213

130-
* `KMACXOF (KMAC128XOF, KMAC256XOF)`
214+
## Contributing
131215

132-
* `Blake3XOF`
216+
Contributions are welcome. Please open an [issue](https://github.com/Xor-el/HashLib4Pascal/issues) for bug reports or feature requests, and submit pull requests.
133217

134-
### Supported Compilers
135-
----------------------------------------
218+
## Other Implementations
136219

137-
* `FreePascal 3.0.0+`
220+
If you want implementations in other languages, you can check out these:
138221

139-
* `Delphi 2010+`
222+
- [HashLib4CPP](https://github.com/ron4fun/HashLib4CPP) by Mbadiwe Nnaemeka Ronald
140223

141-
### Other Implementations
142-
----------------------------------------
224+
## Tip Jar
143225

144-
If you want implementations in other languages, you can check out these
226+
If you find this library useful and would like to support its continued development, tips are greatly appreciated! 🙏
145227

146-
* [HashLib4CPP](https://github.com/ron4fun/HashLib4CPP) by Mbadiwe Nnaemeka Ronald
228+
| Cryptocurrency | Wallet Address |
229+
|---|---|
230+
| <img src="https://raw.githubusercontent.com/spothq/cryptocurrency-icons/master/32/icon/btc.png" width="20" alt="Bitcoin" /> **Bitcoin (BTC)** | `bc1quqhe342vw4ml909g334w9ygade64szqupqulmu` |
231+
| <img src="https://raw.githubusercontent.com/spothq/cryptocurrency-icons/master/32/icon/eth.png" width="20" alt="Ethereum" /> **Ethereum (ETH)** | `0x53651185b7467c27facab542da5868bfebe2bb69` |
232+
| <img src="https://raw.githubusercontent.com/spothq/cryptocurrency-icons/master/32/icon/sol.png" width="20" alt="Solana" /> **Solana (SOL)** | `BPZHjY1eYCdQjLecumvrTJRi5TXj3Yz1vAWcmyEB9Miu` |
147233

148-
### Tip Jar
149-
----------------------------------------
234+
## License
150235

151-
* :dollar: **Bitcoin**: `1MhFfW7tDuEHQSgie65uJcAfJgCNchGeKf`
152-
* :euro: **Ethereum**: `0x6c1DC21aeC49A822A4f1E3bf07c623C2C1978a98`
153-
* :pound: **Pascalcoin**: `345367-40`
236+
HashLib4Pascal is released under the [MIT License](LICENSE).

0 commit comments

Comments
 (0)