Skip to content
pubscout

hashlib

2.4.3, released 7 days ago by bitanon.dev

Secure hash functions, checksums, MACs, KDFs, and RNG optimized for Dart.

WASM-readyRock solid
$ flutter pub add hashlib
Source repository

What it does

Provides a pure-Dart library for cryptographic hash functions, checksum generators, message authentication codes, key derivation functions, and random/UUID generation. It supports one-shot operations and streaming inputs across multiple platforms.

AI-written summary of version 2.4.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need secure hashes, checksums, or key derivation algorithms in pure Dart.
  • You want cross-platform support including Flutter, VM, and Web.

Skip it when

  • You are handling passwords without using a proper KDF like Argon2, scrypt, or bcrypt.
  • You require constant-time execution guarantees that pure Dart environments cannot provide.

Strengths

  • Runs on every platform with no native code or FFI dependencies.
  • Comprehensive collection of algorithms including block hashes, MACs, password KDFs, and OTP generators.
  • Supports both one-shot and streaming computation.

Weaknesses

  • Certain algorithms like XXHash64, XXH3, and XXH128 are not supported on the web platform.
  • Pure-Dart execution cannot guarantee constant-time operation against advanced timing side-channels.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1
import 'package:hashlib/hashlib.dart';

void main() {
  final text = 'Happy Hashing!';
  print(sha256.string(text));
}

Alternatives

Packages that do the same job and could replace hashlib.

  • crypto

    If you prefer the standard package maintained by the Dart team for basic hashing like SHA and MD5.

Works with

Packages commonly used together with hashlib: ones it builds on, ones built on it, and its own family.