cryptography
2.9.0, released 12 months ago by dint.dev
Cross‑platform cryptographic algorithms for Dart and Flutter.
What it does
Provides implementations of encryption, signatures, key exchange, hashing and more. Uses platform‑native APIs when available and falls back to pure‑Dart or WASM otherwise. Supports Android, iOS, web, desktop, and WASM.
AI-written summary of version 2.9.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need cryptographic primitives (AES, ChaCha20, Ed25519, etc.) in a Flutter/Dart app
- You want a single package that works on all target platforms without writing platform‑specific code
Skip it when
- You require a higher‑level authentication flow (OAuth, social sign‑in)
- You need a storage‑focused solution rather than crypto primitives
Strengths
- Platform‑native implementations give best performance
- Pure‑Dart fallback ensures it works everywhere
- Wide algorithm coverage and easy API
Weaknesses
- Not a full authentication framework, only low‑level crypto
- Requires ffi on some platforms for Argon2id
Setup
- Kind
- FFI (native library)
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 5
import 'package:cryptography/cryptography.dart';
final algorithm = AesGcm.with256bits();
final secretKey = await algorithm.newSecretKey();
final nonce = algorithm.nonceLength;
final secretMessage = [1,2,3];
final encrypted = await algorithm.encrypt(secretMessage, secretKey: secretKey);
final decrypted = await algorithm.decrypt(encrypted, secretKey: secretKey);
print('Decrypted: $decrypted');Alternatives
Packages that do the same job and could replace cryptography.
- cryptography_plus
Cryptographic algorithms for encryption, signatures, key agreement, and hashing across platforms.
68Compare - webcrypto
Cross-platform implementation of Web Cryptography APIs for Dart.
89Compare - crypton
A simple Dart library for asymmetric encryption and digital signatures.
50Compare - aws_signature_v4
Dart implementation of AWS Signature Version 4 for signing HTTP requests.
85Compare
Works with
Packages commonly used together with cryptography: ones it builds on, ones built on it, and its own family.
- cryptocryptography depends on itProvides SHA, MD5, and HMAC hashing functions for Dart.
- fficryptography depends on itUtilities for working with Foreign Function Interface (FFI) code in Dart.
- typed_datacryptography depends on itUtility functions and classes for easier work with dart:typed_data lists.
- cryptography_flutterBuilt on cryptographyFlutter plugin that lets the cryptography package use native OS crypto APIs for faster, compliant operations.
- ssiBuilt on cryptographyAffinidi Self-Sovereign Identity library for Dart and Flutter.
- aes256Built on cryptographyAES‑256‑GCM encryption/decryption with PBKDF2‑SHA256 key derivation.
- esp_provisioning_bleBuilt on cryptographyFlutter plugin for Wi-Fi provisioning of ESP32 modules over Bluetooth Low Energy (BLE).
- jwkBuilt on cryptographyEncode and decode JSON Web Keys for use with the cryptography package