Skip to main content

hashlib 3.0.0 copy "hashlib: ^3.0.0" to clipboard
hashlib: ^3.0.0 copied to clipboard

Secure hash functions, checksum generators, and key derivation algorithms optimized for Dart.

hashlib

Fast, pure-Dart hash functions, MACs, KDFs, and secure random.

MD2/4/5 · SHA-1 · SHA-2 · SHA-3 · SHAKE · Keccak · BLAKE2 · BLAKE3 · xxHash · Rapidhash · Whirlpool · RIPEMD · SM3 · Streebog · HMAC · Poly1305 · Argon2 · scrypt · bcrypt · PBKDF2 · HKDF · HOTP / TOTP · CRC · Adler-32 · Secure random · UUID

package version dart support likes pub points codecov Test

A pure-Dart library of secure hash functions, checksums, MACs, key-derivation functions, OTP generators, and secure random — a broad, fast, dependency-light toolbox that runs everywhere Dart does.

hashlib is the middle layer of a three-package family:

convertlib → hashlib → cipherlib

✨ Highlights #

Feature What you get
🌍 Runs on every platform Pure Dart with no native code or FFI, so the same library works everywhere Dart does — the VM, Flutter (Android, iOS, Windows, macOS, Linux), and the web (dart2js and dart2wasm).
🔋 Batteries included Fourteen hash families (MD, SHA-1, SHA-2, SHA-3, SHAKE, Keccak, BLAKE2, BLAKE3, RIPEMD, SM3, Streebog, Whirlpool, xxHash, Rapidhash), checksums (CRC, Adler-32), MACs (HMAC, Poly1305), password KDFs (Argon2, scrypt, bcrypt, PBKDF2), HKDF, TOTP/HOTP, and RNG/UUID generators.
🌊 One-shot or streaming Hash a String or byte buffer in a single call, or feed data incrementally through a reusable sink for large or chunked input.
🔑 Password-grade KDFs Argon2id, scrypt, bcrypt, and PBKDF2 with named security presets that make the cost/latency trade-off explicit.
⚡ Fast Outruns crypto, PointyCastle, and hash in most benchmarks (crypto stays slightly ahead on some 10-byte inputs), see the benchmarks below.
🧩 Codecs and secure random built in Companion codecs and random libraries ship in the same package.

📦 Install #

dependencies:
  hashlib: ^3.0.0

or run dart pub add hashlib. A single import exposes every algorithm:

import 'package:hashlib/hashlib.dart';

Two companion libraries pair well with it — codecs for hex/Base/UTF-8 conversion (re-exported from convertlib) and random for secure random bytes, numbers, and UUIDs:

import 'package:hashlib/codecs.dart'; // toHex, fromHex, toBase64, toUtf8
import 'package:hashlib/random.dart'; // randomBytes, uuid, HashlibRandom

Full API reference: hashlib library.

🧭 Which tool do I need? #

A hash turns any input — text, a file, bytes — into a short, fixed-size "fingerprint". Different jobs need different tools. Here is the plain-English map:

Your goal Reach for Examples
Fingerprint data, detect changes, build a cache key a cryptographic hash sha256, blake2b256
Store a user password safely a password KDF (slow on purpose) argon2id, bcrypt
Prove a message came from someone who knows a secret key a MAC sha256.hmac, poly1305
Quickly catch accidental corruption (not attackers) a checksum crc32, adler32
Generate 2FA / one-time login codes an OTP generator TOTP, HOTP
Generate unguessable tokens, IDs, or salts secure random randomBytes, uuid

Three rules of thumb if you are new to this:

  • Never store a password as a plain hash — not even sha256. Use a KDF like argon2id; it is deliberately slow, which makes guessing passwords expensive.
  • Checksums are not security. crc32, adler32, and the xxHash family are fast but trivial to forge. Use them against accidents, never against an attacker.
  • Unsure which cryptographic hash? sha256 is the safe universal default; blake2b256 is faster. Avoid md5 and sha1 for anything security-related.

⚡ Quickstart #

import 'package:hashlib/hashlib.dart';

void main() {
  // A hex fingerprint of some text — that's the whole idea.
  print(sha256.string('Happy Hashing!').hex());
}

Every algorithm follows the same shape: call it on a String, a List<int>, or a stream, then read the result as hex, Base64, raw bytes, or a BigInt. The Usage section below shows one short recipe per task.

🧬 Supported algorithms #

🧱 Block hash algorithms #

Algorithm Available methods Source
MD2 md2, md2sum RFC-1319
MD4 md4, md4sum RFC-1320
MD5 md5, md5sum RFC-1321
SHA-1 sha1, sha1sum RFC-3174
SHA-2 sha224, sha256, sha384, sha512, sha512t224, sha512t256 RFC-6234
SHA-3 sha3_224, sha3_256, sha3_384, sha3_512 FIPS-202
SHAKE-128 Shake128, shake128, shake128_128, shake128_256 FIPS-202
SHAKE-256 Shake256, shake256, shake256_256, shake256_512 FIPS-202
Keccak keccak224, keccak256, keccak384, keccak512 Team Keccak
Blake2b blake2b160, blake2b256, blake2b384, blake2b512 RFC-7693
Blake2s blake2s128, blake2s160, blake2s224, blake2s256 RFC-7693
BLAKE3 Blake3, blake3, blake3sum, #.of, #.deriveKey BLAKE3
xxHash-32 XXHash32, xxh32, xxh32code Cyan4973
xxHash-64 XXHash64, xxh64, xxh64code Cyan4973
xxHash3-64 XXH3, xxh3, xxh3code Cyan4973
xxHash3-128 XXH128, xxh128, xxh128sum Cyan4973
Rapidhash Rapidhash, rapidhash, rapidhashCode, rapidhashSum Nicoshev
RIPEMD ripemd128, ripemd256, ripemd160, ripemd320 ISO/IEC 10118-3:2018
SM3 sm3, sm3sum GB/T 32905-2016
Streebog streebog256, streebog512, streebog256sum, streebog512sum RFC-6986
Whirlpool whirlpool, whirlpoolsum ISO/IEC 10118-3:2018

Note: On the web, XXHash64, XXH3, and XXH128 run on 32-bit implementations with identical output. Seeds must fit in 53 bits there, and xxh64code/xxh3code may round results above 2^53; use the sum/hex variants for exact values.

🔑 Password / key derivation algorithms #

Algorithm Available methods Source
Argon2 Argon2, argon2d, argon2i, argon2id, argon2Verify RFC-9106
PBKDF2 PBKDF2, pbkdf2, #.pbkdf2 RFC-8018
HKDF HKDF, hkdf, #.hkdf RFC-5869
scrypt Scrypt, scrypt RFC-7914
bcrypt Bcrypt, bcrypt, bcryptSalt, bcryptVerify, bcryptDigest

🏷️ Message authentication codes (MAC) #

Algorithm Available methods Source
HMAC HMAC, #.hmac RFC-2104
Poly1305 Poly1305, poly1305, poly1305auth RFC-8439
BLAKE3 blake3.mac BLAKE3

📱 One-time passwords (2FA) #

Algorithm Available methods Source
HOTP HOTP RFC-4226
TOTP TOTP RFC-6238

✅ Checksums #

Algorithm Available methods Source
CRC crc16, crc32, crc64 Wikipedia
Adler-32 adler32 Wikipedia

🎲 Random and UUID #

The random library provides random number generators through HashlibRandom (secure, system, keccak, sha256, md5, xxh64, sm3), plus helpers like randomBytes, randomNumbers, and randomString. UUID versions v1, v3, v4, v5, v6, v7, and v8 are available through uuid.

🔐 Security notes #

  • Hash passwords with a KDF, not a bare hash. Store argon2id (or scrypt / bcrypt) output with an appropriate security preset — never a plain sha256 of a password — and check it with argon2Verify / bcryptVerify.
  • Compare digests in constant time. Use HashDigest.isEqual when verifying MACs and digests instead of == or a manual byte loop, to avoid leaking information through timing.
  • Legacy algorithms are for compatibility only. MD2, MD4, MD5, and SHA-1 are cryptographically broken; use them only for interop or non-security checksums, and prefer SHA-256, SHA-3, or BLAKE2 for new work.
  • Non-cryptographic hashes. CRC, Adler-32, and the xxHash family are fast integrity and lookup hashes, not secure against adversaries — do not use them where collision or preimage resistance matters.
  • Runtime timing. Pure-Dart execution (JIT, AOT, dart2js) is not guaranteed to run in constant time; weigh the deployment environment before relying on it in side-channel-sensitive settings.

🧪 Testing and reliability #

Correctness is the first-order goal of this library, and the test suite is built to enforce it. There are 700 test cases across 60+ files that runs after every change and before each release across three platforms: the Dart VM, Node.js, and Chrome (WASM).

Every algorithm is checked in several independent ways:

  • Official known-answer vectors. Digests are pinned against the published test vectors from the relevant standard — RFCs, FIPS/NIST publications, and each algorithm's reference implementation. Expected values are never invented; each vector cites its source in the test file.
  • Differential cross-validation. For every algorithm that a mature, independent Dart package also implements, the output is compared byte-for-byte against crypto and pointycastle over hundreds of random inputs. This currently covers MD2, MD4, MD5, SHA-1, SHA-224/256/384/512, SHA-512/224, SHA-512/256, SHA3 (224–512), Keccak (224–512), RIPEMD-128/160/256/320, BLAKE2b, SM3, and HMAC. A subtle divergence in padding, endianness, or a block boundary would fail these tests even if it slipped past a fixed vector.
  • Boundary and edge coverage. Inputs are exercised at the empty string, single bytes, and lengths straddling each algorithm's internal block/rate size (e.g. block−1, block, block+1, and multi-block messages) - the exact places where length-encoding and padding bugs hide.
  • Streaming equals one-shot. Chunked/streamed input and the incremental Sink API (including reset(), double-close(), and use-after-close) are verified to produce identical digests to the one-shot path.
  • Argument validation. Invalid key, salt, digest, and parameter lengths are asserted to throw typed errors rather than silently producing weak output.

The algorithms compute exactly what their standards define, verified against official vectors and multiple independent implementations. Please still read the Security notes above: choose the right primitive for your threat model (a KDF for passwords, a cryptographic hash rather than a checksum where an adversary is involved), and note that pure-Dart execution makes no hard constant-time guarantee.

You can reproduce all of this locally:

dart test              # vm, node, and chrome
dart test -p vm        # fast, VM-only iteration

🍳 Usage #

Short, focused snippets follow — one per task. Every algorithm listed in the tables above plugs into the same calls, and full runnable programs live in the example folder.

Hash text or bytes #

Turn any input into a fingerprint and read it in whatever format you need:

final digest = sha256.string('Happy Hashing!');

print(digest);           // hex string (the default when printed)
print(digest.hex());     // "d8d0..."  same value, explicit
print(digest.base64());  // Base64 encoding
digest.bytes;            // raw bytes as a Uint8List

sha256.convert([1, 2, 3]);      // hash a List<int> of bytes instead
sha256sum('Happy Hashing!');    // shortcut straight to a hex String

Swap sha256 for any hash — md5, sha3_256, blake2b512, sm3, and the rest all share this exact API.

Hash a large file or stream #

Feed data in chunks instead of loading everything into memory. The result is identical to hashing it all at once:

final sink = sha256.createSink();
sink.add(firstChunk);   // each chunk is a List<int>
sink.add(nextChunk);
final digest = sink.digest();

Store and verify a password #

Hash the password with a slow KDF and a fresh random salt, then store only the encoded result. To check a login, verify against that string — nothing is ever decrypted:

import 'package:hashlib/hashlib.dart';
import 'package:hashlib/random.dart'; // for randomBytes

// Sign-up: hash and store.
final salt = randomBytes(16);
final stored = argon2id(password.codeUnits, salt).encoded();
// stored => "$argon2id$v=19$m=65536,t=3,p=4$..."  safe to save in your database

// Login: check the password against the stored hash.
final ok = argon2Verify(stored, password.codeUnits); // true / false

bcrypt works the same way and generates its own salt:

final stored = bcrypt(password.codeUnits);
final ok = bcryptVerify(stored, password.codeUnits);

Both accept a security: preset (test, little, moderate, good, strong) that trades speed for resistance to guessing — pick the strongest your latency budget allows, e.g. argon2id(password.codeUnits, salt, security: Argon2Security.moderate).

Authenticate a message with a key (HMAC) #

A MAC proves a message was not tampered with by anyone who does not know the shared key. Attach .hmac to any hash:

final tag = sha256.hmac.byString('shared-secret-key').string('transfer 100 coins');

// The receiver recomputes the tag and compares it in constant time:
final valid = tag.isEqual(receivedTag);

Compare tags with isEqual() (constant-time), never with == on the hex string — a plain comparison can leak the answer through timing.

Fast checksum for accidental corruption #

Cheap integrity checks against bit-rot and transfer errors — not attackers:

crc32code('Happy Hashing!');   // => 3003384410 (an int)
adler32code('Happy Hashing!'); // another fast, non-secure checksum

One-time passwords (2FA) #

final secret = 'my-shared-secret'.codeUnits;

TOTP(secret).value();                  // 6-digit code, rotates every 30 seconds
HOTP(secret, counter: counter).value(); // counter-based code (counter is bytes)

final totp = TOTP(secret, label: 'alice@example.com', issuer: 'Example');
totp.verify(int.parse(userInput));      // true within +/- 1 period of drift
totp.uri; // otpauth://totp/Example:alice@example.com?secret=... (for a QR code)

Secure random values and UUIDs #

import 'package:hashlib/codecs.dart'; // for toHex
import 'package:hashlib/random.dart';

randomBytes(16);          // 16 cryptographically-secure bytes (great for a salt)
toHex(randomBytes(16));   // the same, as a hex string
randomString(32);         // a random text token
uuid.v4();                // a random UUID (v1/v3/v5/v6/v7/v8 also available)

🚀 Benchmarks #

Libraries #

Hash Functions #

Algorithm Library 2MB message 1KB message 10B message
MD5 hashlib ████████████████
3.82 Gbps 🌟
████████████████
3.48 Gbps 🌟
████████████████
378 Mbps 🌟
crypto ███████████████░
3.47 Gbps 🔻1.1x
██████████████░░
3.15 Gbps 🔻1.1x
███████████████░
345 Mbps 🔻1.09x
hash ██░░░░░░░░░░░░░░
379 Mbps 🔻10.08x
██░░░░░░░░░░░░░░
511 Mbps 🔻6.82x
███░░░░░░░░░░░░░
64.91 Mbps 🔻5.82x
PointyCastle ███░░░░░░░░░░░░░
710 Mbps 🔻5.38x
███░░░░░░░░░░░░░
659 Mbps 🔻5.28x
████░░░░░░░░░░░░
101 Mbps 🔻3.74x
HMAC(MD5) hashlib ████████████████
3.85 Gbps 🌟
████████████████
2.78 Gbps 🌟
████████████████
96.33 Mbps 🌟
crypto ██████████████░░
3.46 Gbps 🔻1.11x
██████████████░░
2.51 Gbps 🔻1.11x
███████████████░
90.24 Mbps 🔻1.07x
hash ██░░░░░░░░░░░░░░
378 Mbps 🔻10.19x
██░░░░░░░░░░░░░░
406 Mbps 🔻6.87x
███░░░░░░░░░░░░░
15.9 Mbps 🔻6.06x
SHA-1 hashlib ████████████████
1.81 Gbps 🌟
████████████████
1.66 Gbps 🌟
████████████████
199 Mbps 🌟
crypto ███████████░░░░░
1.3 Gbps 🔻1.39x
████████████░░░░
1.2 Gbps 🔻1.39x
█████████████░░░
158 Mbps 🔻1.26x
PointyCastle ████░░░░░░░░░░░░
431 Mbps 🔻4.21x
████░░░░░░░░░░░░
394 Mbps 🔻4.22x
████░░░░░░░░░░░░
46.19 Mbps 🔻4.31x
hash ██░░░░░░░░░░░░░░
261 Mbps 🔻6.93x
███░░░░░░░░░░░░░
305 Mbps 🔻5.45x
███░░░░░░░░░░░░░
41.4 Mbps 🔻4.81x
cryptography ███████████░░░░░
1.3 Gbps 🔻1.39x
████████████░░░░
1.2 Gbps 🔻1.38x
█████████████░░░
157 Mbps 🔻1.27x
HMAC(SHA-1) hashlib ████████████████
1.81 Gbps 🌟
████████████████
1.16 Gbps 🌟
████████████████
31.99 Mbps 🌟
crypto ███████████░░░░░
1.3 Gbps 🔻1.39x
████████████░░░░
859 Mbps 🔻1.35x
████████████░░░░
24.85 Mbps 🔻1.29x
cryptography ███████████░░░░░
1.3 Gbps 🔻1.39x
██████████░░░░░░
749 Mbps 🔻1.55x
█████████░░░░░░░
17.24 Mbps 🔻1.86x
SHA-224 hashlib ████████████████
1.44 Gbps 🌟
████████████████
1.33 Gbps 🌟
████████████████
165 Mbps 🌟
crypto ███████████████░
1.34 Gbps 🔻1.07x
███████████████░
1.22 Gbps 🔻1.08x
██████████████░░
140 Mbps 🔻1.18x
hash ██░░░░░░░░░░░░░░
155 Mbps 🔻9.25x
██░░░░░░░░░░░░░░
169 Mbps 🔻7.87x
██░░░░░░░░░░░░░░
24.27 Mbps 🔻6.79x
PointyCastle ██░░░░░░░░░░░░░░
176 Mbps 🔻8.16x
██░░░░░░░░░░░░░░
168 Mbps 🔻7.89x
██░░░░░░░░░░░░░░
24.51 Mbps 🔻6.73x
cryptography ████████░░░░░░░░
727 Mbps 🔻1.98x
████████░░░░░░░░
689 Mbps 🔻1.93x
████████████░░░░
119 Mbps 🔻1.38x
SHA-256 hashlib ████████████████
1.44 Gbps 🌟
████████████████
1.33 Gbps 🌟
████████████████
165 Mbps 🌟
crypto ███████████████░
1.34 Gbps 🔻1.07x
███████████████░
1.23 Gbps 🔻1.08x
██████████████░░
142 Mbps 🔻1.16x
hash ██░░░░░░░░░░░░░░
156 Mbps 🔻9.23x
██░░░░░░░░░░░░░░
168 Mbps 🔻7.92x
██░░░░░░░░░░░░░░
24.48 Mbps 🔻6.72x
PointyCastle ██░░░░░░░░░░░░░░
181 Mbps 🔻7.94x
██░░░░░░░░░░░░░░
169 Mbps 🔻7.87x
██░░░░░░░░░░░░░░
24.08 Mbps 🔻6.83x
cryptography ████████░░░░░░░░
731 Mbps 🔻1.97x
████████░░░░░░░░
689 Mbps 🔻1.93x
███████████░░░░░
117 Mbps 🔻1.4x
HMAC(SHA-256) hashlib ████████████████
1.42 Gbps 🌟
████████████████
935 Mbps 🌟
████████████████
26.07 Mbps 🌟
crypto ███████████████░
1.34 Gbps 🔻1.06x
███████████████░
861 Mbps 🔻1.09x
███████████████░
23.76 Mbps 🔻1.1x
cryptography ████████░░░░░░░░
686 Mbps 🔻2.07x
████████░░░░░░░░
486 Mbps 🔻1.92x
█████████░░░░░░░
14.17 Mbps 🔻1.84x
SHA-384 hashlib ████████████████
2.32 Gbps 🌟
████████████████
1.95 Gbps 🌟
████████████████
120 Mbps 🌟
crypto █████████████░░░
1.91 Gbps 🔻1.21x
█████████████░░░
1.6 Gbps 🔻1.22x
█████████████░░░
97.29 Mbps 🔻1.24x
hash █░░░░░░░░░░░░░░░
127 Mbps 🔻18.29x
█░░░░░░░░░░░░░░░
149 Mbps 🔻13.09x
██░░░░░░░░░░░░░░
12.22 Mbps 🔻9.85x
PointyCastle █░░░░░░░░░░░░░░░
43.36 Mbps 🔻53.49x
█░░░░░░░░░░░░░░░
38.27 Mbps 🔻51.07x
█░░░░░░░░░░░░░░░
3.21 Mbps 🔻37.51x
cryptography █████████████░░░
1.9 Gbps 🔻1.22x
█████████████░░░
1.6 Gbps 🔻1.22x
█████████████░░░
96.38 Mbps 🔻1.25x
SHA-512 hashlib ████████████████
2.32 Gbps 🌟
████████████████
1.95 Gbps 🌟
████████████████
114 Mbps 🌟
crypto █████████████░░░
1.9 Gbps 🔻1.22x
█████████████░░░
1.6 Gbps 🔻1.22x
██████████████░░
98.32 Mbps 🔻1.16x
hash █░░░░░░░░░░░░░░░
127 Mbps 🔻18.2x
█░░░░░░░░░░░░░░░
151 Mbps 🔻12.93x
██░░░░░░░░░░░░░░
12.22 Mbps 🔻9.32x
PointyCastle █░░░░░░░░░░░░░░░
43.41 Mbps 🔻53.42x
█░░░░░░░░░░░░░░░
38.19 Mbps 🔻51.07x
█░░░░░░░░░░░░░░░
3.2 Mbps 🔻35.57x
cryptography █████████████░░░
1.91 Gbps 🔻1.22x
█████████████░░░
1.6 Gbps 🔻1.22x
██████████████░░
98 Mbps 🔻1.16x
HMAC(SHA-512) hashlib ████████████████
2.32 Gbps 🌟
████████████████
1.34 Gbps 🌟
████████████████
30.83 Mbps 🌟
crypto █████████████░░░
1.91 Gbps 🔻1.22x
██████████████░░
1.14 Gbps 🔻1.18x
██████████████░░
27.91 Mbps 🔻1.1x
cryptography █████████████░░░
1.91 Gbps 🔻1.21x
███████████░░░░░
891 Mbps 🔻1.51x
█████████░░░░░░░
16.47 Mbps 🔻1.87x
SHA-512/224 hashlib ████████████████
2.32 Gbps 🌟
████████████████
1.95 Gbps 🌟
████████████████
118 Mbps 🌟
crypto █████████████░░░
1.91 Gbps 🔻1.22x
█████████████░░░
1.6 Gbps 🔻1.22x
█████████████░░░
99.18 Mbps 🔻1.19x
PointyCastle █░░░░░░░░░░░░░░░
43.42 Mbps 🔻53.43x
█░░░░░░░░░░░░░░░
34.43 Mbps 🔻56.74x
█░░░░░░░░░░░░░░░
1.65 Mbps 🔻71.72x
SHA-512/256 hashlib ████████████████
2.32 Gbps 🌟
████████████████
1.96 Gbps 🌟
████████████████
119 Mbps 🌟
crypto █████████████░░░
1.91 Gbps 🔻1.22x
█████████████░░░
1.61 Gbps 🔻1.22x
██████████████░░
102 Mbps 🔻1.16x
PointyCastle █░░░░░░░░░░░░░░░
43.29 Mbps 🔻53.61x
█░░░░░░░░░░░░░░░
34.5 Mbps 🔻56.78x
█░░░░░░░░░░░░░░░
1.65 Mbps 🔻72.11x
SHA3-224 hashlib ████████████████
2.19 Gbps 🌟
████████████████
1.91 Gbps 🌟
████████████████
133 Mbps 🌟
PointyCastle █░░░░░░░░░░░░░░░
25.37 Mbps 🔻86.18x
█░░░░░░░░░░░░░░░
22.89 Mbps 🔻83.49x
█░░░░░░░░░░░░░░░
1.77 Mbps 🔻75.24x
sha3 █░░░░░░░░░░░░░░░
161 Mbps 🔻13.6x
█░░░░░░░░░░░░░░░
170 Mbps 🔻11.23x
██░░░░░░░░░░░░░░
18.98 Mbps 🔻7.03x
SHA3-256 hashlib ████████████████
2.07 Gbps 🌟
████████████████
1.92 Gbps 🌟
████████████████
134 Mbps 🌟
PointyCastle █░░░░░░░░░░░░░░░
24.43 Mbps 🔻84.72x
█░░░░░░░░░░░░░░░
22.87 Mbps 🔻83.82x
█░░░░░░░░░░░░░░░
1.76 Mbps 🔻75.9x
sha3 █░░░░░░░░░░░░░░░
178 Mbps 🔻11.64x
█░░░░░░░░░░░░░░░
170 Mbps 🔻11.26x
██░░░░░░░░░░░░░░
18.97 Mbps 🔻7.05x
SHA3-384 hashlib ████████████████
1.6 Gbps 🌟
████████████████
1.55 Gbps 🌟
████████████████
133 Mbps 🌟
PointyCastle █░░░░░░░░░░░░░░░
18.67 Mbps 🔻85.83x
█░░░░░░░░░░░░░░░
18.38 Mbps 🔻84.54x
█░░░░░░░░░░░░░░░
1.77 Mbps 🔻75.35x
sha3 █░░░░░░░░░░░░░░░
148 Mbps 🔻10.83x
██░░░░░░░░░░░░░░
147 Mbps 🔻10.55x
██░░░░░░░░░░░░░░
18.91 Mbps 🔻7.04x
SHA3-512 hashlib ████████████████
1.12 Gbps 🌟
████████████████
1.05 Gbps 🌟
████████████████
133 Mbps 🌟
PointyCastle █░░░░░░░░░░░░░░░
12.89 Mbps 🔻86.69x
█░░░░░░░░░░░░░░░
12.22 Mbps 🔻85.82x
█░░░░░░░░░░░░░░░
1.75 Mbps 🔻75.61x
sha3 ██░░░░░░░░░░░░░░
113 Mbps 🔻9.89x
██░░░░░░░░░░░░░░
110 Mbps 🔻9.55x
██░░░░░░░░░░░░░░
18.75 Mbps 🔻7.07x
SHAKE-128 hashlib ████████████████
2.52 Gbps 🌟
████████████████
1.71 Gbps 🌟
████████████████
126 Mbps 🌟
PointyCastle █░░░░░░░░░░░░░░░
30.14 Mbps 🔻83.73x
█░░░░░░░░░░░░░░░
24.79 Mbps 🔻68.93x
█░░░░░░░░░░░░░░░
1.76 Mbps 🔻71.66x
sha3 █░░░░░░░░░░░░░░░
139 Mbps 🔻18.11x
██░░░░░░░░░░░░░░
184 Mbps 🔻9.28x
██░░░░░░░░░░░░░░
18.69 Mbps 🔻6.75x
SHAKE-256 hashlib ████████████████
2.07 Gbps 🌟
████████████████
1.87 Gbps 🌟
████████████████
117 Mbps 🌟
PointyCastle █░░░░░░░░░░░░░░░
24.34 Mbps 🔻85.06x
█░░░░░░░░░░░░░░░
22.88 Mbps 🔻81.61x
█░░░░░░░░░░░░░░░
1.77 Mbps 🔻66.48x
sha3 █░░░░░░░░░░░░░░░
175 Mbps 🔻11.84x
█░░░░░░░░░░░░░░░
170 Mbps 🔻10.99x
███░░░░░░░░░░░░░
18.74 Mbps 🔻6.26x
Keccak-224 hashlib ████████████████
2.19 Gbps 🌟
████████████████
1.91 Gbps 🌟
████████████████
102 Mbps 🌟
PointyCastle █░░░░░░░░░░░░░░░
25.83 Mbps 🔻84.75x
█░░░░░░░░░░░░░░░
22.91 Mbps 🔻83.57x
█░░░░░░░░░░░░░░░
1.7 Mbps 🔻59.91x
sha3 █░░░░░░░░░░░░░░░
184 Mbps 🔻11.9x
█░░░░░░░░░░░░░░░
98.68 Mbps 🔻19.4x
███░░░░░░░░░░░░░
18.41 Mbps 🔻5.54x
Keccak-256 hashlib ████████████████
2.02 Gbps 🌟
████████████████
1.91 Gbps 🌟
████████████████
133 Mbps 🌟
PointyCastle █░░░░░░░░░░░░░░░
21.1 Mbps 🔻95.92x
█░░░░░░░░░░░░░░░
22.86 Mbps 🔻83.67x
█░░░░░░░░░░░░░░░
1.77 Mbps 🔻75.18x
sha3 █░░░░░░░░░░░░░░░
178 Mbps 🔻11.38x
█░░░░░░░░░░░░░░░
170 Mbps 🔻11.23x
██░░░░░░░░░░░░░░
18.98 Mbps 🔻7x
Keccak-384 hashlib ████████████████
1.6 Gbps 🌟
████████████████
1.55 Gbps 🌟
████████████████
133 Mbps 🌟
PointyCastle █░░░░░░░░░░░░░░░
18.54 Mbps 🔻86.41x
█░░░░░░░░░░░░░░░
18.28 Mbps 🔻84.66x
█░░░░░░░░░░░░░░░
1.76 Mbps 🔻75.71x
sha3 █░░░░░░░░░░░░░░░
145 Mbps 🔻11.02x
██░░░░░░░░░░░░░░
147 Mbps 🔻10.51x
██░░░░░░░░░░░░░░
18.92 Mbps 🔻7.04x
Keccak-512 hashlib ████████████████
1.12 Gbps 🌟
████████████████
1.05 Gbps 🌟
████████████████
133 Mbps 🌟
PointyCastle █░░░░░░░░░░░░░░░
12.9 Mbps 🔻86.6x
█░░░░░░░░░░░░░░░
12.24 Mbps 🔻85.8x
█░░░░░░░░░░░░░░░
1.76 Mbps 🔻75.44x
sha3 ██░░░░░░░░░░░░░░
115 Mbps 🔻9.7x
██░░░░░░░░░░░░░░
110 Mbps 🔻9.54x
██░░░░░░░░░░░░░░
18.95 Mbps 🔻7.01x
RIPEMD-128 hashlib ████████████████
2.33 Gbps 🌟
████████████████
2.12 Gbps 🌟
████████████████
231 Mbps 🌟
PointyCastle ███░░░░░░░░░░░░░
397 Mbps 🔻5.86x
███░░░░░░░░░░░░░
374 Mbps 🔻5.66x
████░░░░░░░░░░░░
60.34 Mbps 🔻3.82x
RIPEMD-160 hashlib ████████████████
716 Mbps 🌟
████████████████
666 Mbps 🌟
████████████████
90.85 Mbps 🌟
hash █████░░░░░░░░░░░
212 Mbps 🔻3.37x
██████░░░░░░░░░░
237 Mbps 🔻2.81x
██████░░░░░░░░░░
34.36 Mbps 🔻2.64x
PointyCastle █████░░░░░░░░░░░
211 Mbps 🔻3.39x
█████░░░░░░░░░░░
198 Mbps 🔻3.36x
██████░░░░░░░░░░
31.78 Mbps 🔻2.86x
RIPEMD-256 hashlib ████████████████
2.7 Gbps 🌟
████████████████
2.41 Gbps 🌟
████████████████
229 Mbps 🌟
PointyCastle ██░░░░░░░░░░░░░░
403 Mbps 🔻6.7x
███░░░░░░░░░░░░░
379 Mbps 🔻6.36x
████░░░░░░░░░░░░
59.66 Mbps 🔻3.84x
RIPEMD-320 hashlib ████████████████
718 Mbps 🌟
████████████████
666 Mbps 🌟
████████████████
89.05 Mbps 🌟
PointyCastle █████░░░░░░░░░░░
209 Mbps 🔻3.44x
█████░░░░░░░░░░░
200 Mbps 🔻3.32x
██████░░░░░░░░░░
30.93 Mbps 🔻2.88x
BLAKE-2s hashlib ████████████████
1.9 Gbps 🌟
████████████████
1.87 Gbps 🌟
████████████████
201 Mbps 🌟
cryptography █████████░░░░░░░
1.06 Gbps 🔻1.8x
█████████░░░░░░░
1.04 Gbps 🔻1.79x
█████████████░░░
168 Mbps 🔻1.19x
BLAKE-2b hashlib ████████████████
4.72 Gbps 🌟
████████████████
4.48 Gbps 🌟
████████████████
191 Mbps 🌟
PointyCastle █░░░░░░░░░░░░░░░
103 Mbps 🔻45.6x
█░░░░░░░░░░░░░░░
102 Mbps 🔻44.02x
█░░░░░░░░░░░░░░░
7.69 Mbps 🔻24.91x
cryptography █████░░░░░░░░░░░
1.4 Gbps 🔻3.36x
█████░░░░░░░░░░░
1.37 Gbps 🔻3.28x
█████████░░░░░░░
103 Mbps 🔻1.87x
BLAKE3 hashlib ████████████████
1.78 Gbps 🌟
████████████████
1.83 Gbps 🌟
████████████████
157 Mbps 🌟
Poly1305 hashlib ████████████████
6.03 Gbps 🌟
████████████████
5.69 Gbps 🌟
████████████████
644 Mbps 🌟
PointyCastle ███░░░░░░░░░░░░░
1.29 Gbps 🔻4.67x
███░░░░░░░░░░░░░
1.24 Gbps 🔻4.6x
█████████░░░░░░░
345 Mbps 🔻1.87x
cryptography █░░░░░░░░░░░░░░░
542 Mbps 🔻11.12x
█░░░░░░░░░░░░░░░
531 Mbps 🔻10.72x
███░░░░░░░░░░░░░
129 Mbps 🔻4.99x
XXH32 hashlib ████████████████
8.57 Gbps 🌟
████████████████
8.01 Gbps 🌟
████████████████
1.32 Gbps 🌟
XXH64 hashlib ████████████████
15.83 Gbps 🌟
████████████████
14.42 Gbps 🌟
████████████████
1.3 Gbps 🌟
XXH3 hashlib ████████████████
49.74 Gbps 🌟
████████████████
22.3 Gbps 🌟
██░░░░░░░░░░░░░░
603 Mbps
xxh3 ████████░░░░░░░░
24.32 Gbps 🔻2.05x
███████████████░
21.3 Gbps 🔻1.05x
████████████████
5.24 Gbps 🔺8.69x
XXH128 hashlib ████████████████
50.44 Gbps 🌟
████████████████
20.97 Gbps 🌟
████████████████
540 Mbps 🌟
Rapidhash hashlib ████████████████
56.33 Gbps 🌟
████████████████
33.76 Gbps 🌟
████████████████
1.3 Gbps 🌟
SM3 hashlib ████████████████
932 Mbps 🌟
████████████████
859 Mbps 🌟
████████████████
118 Mbps 🌟
PointyCastle ███░░░░░░░░░░░░░
179 Mbps 🔻5.21x
███░░░░░░░░░░░░░
167 Mbps 🔻5.16x
████░░░░░░░░░░░░
26.62 Mbps 🔻4.44x
Streebog-256 hashlib ████████████████
246 Mbps 🌟
████████████████
207 Mbps 🌟
████████████████
12.62 Mbps 🌟
Streebog-512 hashlib ████████████████
247 Mbps 🌟
████████████████
207 Mbps 🌟
████████████████
12.59 Mbps 🌟
Whirlpool hashlib ████████████████
436 Mbps 🌟
████████████████
409 Mbps 🌟
████████████████
59.63 Mbps 🌟
PointyCastle ██░░░░░░░░░░░░░░
65.16 Mbps 🔻6.68x
██░░░░░░░░░░░░░░
60.71 Mbps 🔻6.74x
██░░░░░░░░░░░░░░
8.63 Mbps 🔻6.91x
MD2 hashlib ████████████████
82.6 Mbps 🌟
████████████████
80.01 Mbps 🌟
████████████████
25.87 Mbps 🌟
PointyCastle █░░░░░░░░░░░░░░░
643 Kbps 🔻128.43x
███████████░░░░░
53.18 Mbps 🔻1.5x
███████████░░░░░
18.14 Mbps 🔻1.43x
MD4 hashlib ████████████████
3.74 Gbps 🌟
████████████████
3.3 Gbps 🌟
████████████████
296 Mbps 🌟
PointyCastle ███░░░░░░░░░░░░░
783 Mbps 🔻4.78x
████░░░░░░░░░░░░
726 Mbps 🔻4.54x
██████░░░░░░░░░░
116 Mbps 🔻2.56x
CRC16 hashlib ████████████████
9.09 Gbps 🌟
████████████████
8.97 Gbps 🌟
████████████████
4.71 Gbps 🌟
CRC32 hashlib ████████████████
8.52 Gbps 🌟
████████████████
8.41 Gbps 🌟
████████████████
4.5 Gbps 🌟
archive ███████░░░░░░░░░
3.79 Gbps 🔻2.25x
███████░░░░░░░░░
3.8 Gbps 🔻2.22x
████████████████
4.39 Gbps 🔻1.02x
CRC64 hashlib ████████████████
6.98 Gbps 🌟
████████████████
5.56 Gbps 🌟
█████████████░░░
3.49 Gbps
archive ██████████░░░░░░
4.26 Gbps 🔻1.64x
████████████░░░░
4.27 Gbps 🔻1.3x
████████████████
4.31 Gbps 🔺1.24x
Adler-32 hashlib ████████████████
13.95 Gbps 🌟
████████████████
13.65 Gbps 🌟
████████████████
5.02 Gbps 🌟
archive ██████████░░░░░░
8.52 Gbps 🔻1.64x
██████████░░░░░░
8.41 Gbps 🔻1.62x
██████████████░░
4.53 Gbps 🔻1.11x

Key Expansion #

Algorithm Library 32B key 256B key 7.97KB key
HKDF-SHA256 hashlib ████████████████
52.47 Mbps 🌟
████████████████
164 Mbps 🌟
████████████████
233 Mbps 🌟
PointyCastle ██░░░░░░░░░░░░░░
8.15 Mbps 🔻6.44x
██░░░░░░░░░░░░░░
17.75 Mbps 🔻9.26x
█░░░░░░░░░░░░░░░
21.22 Mbps 🔻10.98x

One-Time Passwords and UUIDs #

Algorithm Library Per second
HOTP-SHA1 hashlib ████████████████
591.71K/s 🌟
otp ███████░░░░░░░░░
275.12K/s 🔻2.15x
TOTP-SHA1 hashlib ████████████████
589.1K/s 🌟
otp ███████░░░░░░░░░
270.63K/s 🔻2.18x
UUID v1 hashlib ████████████████
8.39M/s 🌟
uuid ███████░░░░░░░░░
3.67M/s 🔻2.28x
UUID v4 hashlib ████████████████
3.03M/s 🌟
uuid █████████░░░░░░░
1.76M/s 🔻1.72x
UUID v5 hashlib ████████████████
1.13M/s 🌟
uuid ██░░░░░░░░░░░░░░
136.43K/s 🔻8.3x
UUID v6 hashlib ████████████████
8.26M/s 🌟
uuid ████░░░░░░░░░░░░
2.31M/s 🔻3.58x
UUID v7 hashlib ████████████████
2.95M/s 🌟
uuid ███████░░░░░░░░░
1.27M/s 🔻2.33x

Key Derivators #

Algorithm Library little moderate good strong
scrypt hashlib ████████████████
1.13 ms 🌟
████████████████
12.96 ms 🌟
████████████████
72.83 ms 🌟
████████████████
2379.37 ms 🌟
PointyCastle ███████░░░░░░░░░
2.51 ms 🔻2.22x
████████░░░░░░░░
25.7 ms 🔻1.98x
█████████░░░░░░░
130.53 ms 🔻1.79x
-
bcrypt hashlib ████████████████
1.63 ms 🌟
████████████████
12.73 ms 🌟
████████████████
203.11 ms 🌟
████████████████
1627.3 ms 🌟
bcrypt ████████████░░░░
2.17 ms 🔻1.34x
████████████░░░░
16.87 ms 🔻1.33x
████████████░░░░
269.12 ms 🔻1.33x
-
PBKDF2-HMAC-SHA256 hashlib ████████████████
0.52 ms 🌟
████████████████
6.06 ms 🌟
████████████████
101.47 ms 🌟
████████████████
1212.69 ms 🌟
PointyCastle ███░░░░░░░░░░░░░
2.37 ms 🔻4.58x
█░░░░░░░░░░░░░░░
70.89 ms 🔻11.69x
█░░░░░░░░░░░░░░░
1181.58 ms 🔻11.64x
-
cryptography ████████████░░░░
0.71 ms 🔻1.37x
█████░░░░░░░░░░░
21.25 ms 🔻3.5x
█████░░░░░░░░░░░
353.13 ms 🔻3.48x
-
Argon2i hashlib ████████████████
2.44 ms 🌟
████████████████
17.05 ms 🌟
████████████████
219.54 ms 🌟
████████████████
2408.45 ms 🌟
Argon2d hashlib ████████████████
2.35 ms 🌟
████████████████
16.95 ms 🌟
████████████████
213.21 ms 🌟
████████████████
2400.36 ms 🌟
Argon2id hashlib ████████████████
2.36 ms 🌟
████████████████
16.93 ms 🌟
████████████████
212.51 ms 🌟
████████████████
2392.92 ms 🌟
argon2 ███░░░░░░░░░░░░░
10.9 ms 🔻4.62x
██████░░░░░░░░░░
46.27 ms 🔻2.73x
██████░░░░░░░░░░
555.52 ms 🔻2.61x
-
cryptography ████████░░░░░░░░
4.69 ms 🔻1.99x
████████░░░░░░░░
33.85 ms 🔻2x
████████░░░░░░░░
425.59 ms 🔻2x
-

All benchmarks are done on AMD Ryzen 7 5800X CPU + 3200MHz RAM using compiled exe

Dart SDK version: 3.14.0 (stable) (Wed Nov 4 16:28:39 2026 -0800) on "windows_x64"

📄 License #

BSD 3-Clause License. See the LICENSE file for details. Issues and contributions are welcome at github.com/bitanon/hashlib.

73
likes
160
points
68.8k
downloads

Documentation

API reference

Publisher

verified publisherbitanon.dev

Weekly Downloads

Secure hash functions, checksum generators, and key derivation algorithms optimized for Dart.

Homepage
Repository (GitHub)
View/report issues

Funding

Consider supporting this project:

paypal.me

License

BSD-3-Clause (license)

Dependencies

convertlib

More

Packages that depend on hashlib