Skip to content
pubscout

cryptography

2.9.0, released 12 months ago by dint.dev

Cross‑platform cryptographic algorithms for Dart and Flutter.

WASM-ready
$ flutter pub add cryptography
Source repository

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.

  • webcrypto

    Cross-platform implementation of Web Cryptography APIs for Dart.

  • crypton

    A simple Dart library for asymmetric encryption and digital signatures.

  • aws_signature_v4

    Dart implementation of AWS Signature Version 4 for signing HTTP requests.

Works with

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