webcrypto
0.6.2, released 9 days ago by google.dev
Cross-platform implementation of Web Cryptography APIs for Dart.
What it does
Provides a cross-platform implementation of the Web Cryptography API across Android, iOS, Web, Windows, Linux, and macOS. Outside the browser it embeds BoringSSL using dart:ffi, and inside the browser it wraps window.crypto.
AI-written summary of version 0.6.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need cryptographic operations like hashing, signing, encryption, or key derivation that work identically across mobile, web, and desktop.
- You want to use standard Web Cryptography APIs in Dart and Flutter.
Skip it when
- You need features missing from the Web Cryptography API or package limitations like deriveKey, wrapKey, unwrapKey, or AES-KW.
- Your system lacks cmake or a C compiler required to build BoringSSL via hooks.
Strengths
- Consistent API across mobile, web, and desktop platforms.
- Backed by BoringSSL natively and window.crypto on the web.
- Extensive feature set including AES, RSA, ECDSA, HMAC, and hashing algorithms.
Weaknesses
- Requires cmake and a C compiler (like gcc or clang) for native builds.
- Native implementation executes on the main thread.
- Some browser and platform specific compatibility limitations and known issues.
Setup
- Kind
- FFI (native library)
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 5
Your system must have cmake and a C compiler (like gcc or clang) installed to build BoringSSL using hooks.
import 'dart:convert' show utf8;
import 'package:webcrypto/webcrypto.dart';
Future<void> main() async {
final digest = await Hash.sha256.digestBytes(utf8.encode('Hello World'));
}Alternatives
Packages that do the same job and could replace webcrypto.
- blockchain_utils
Comprehensive pure-Dart cryptography and blockchain toolkit with optional Rust backend.
72Compare - crypto
Provides SHA, MD5, and HMAC hashing functions for Dart.
96Compare - cryptography_flutter_plus
Flutter plugin to use platform APIs for package:cryptography_plus
73Compare - pqforge
Pure-Dart post-quantum cryptography for ML-KEM, ML-DSA, SLH-DSA, and HPKE.
71Compare
Works with
Packages commonly used together with webcrypto: ones it builds on, ones built on it, and its own family.
- hookswebcrypto depends on itDart API for the JSON-based protocol for package build and link hooks.
- code_assetswebcrypto depends on itProvides the hook protocol specification for bundling native code with Dart packages.
- ffiwebcrypto depends on itUtilities for working with Foreign Function Interface (FFI) code in Dart.
- native_toolchain_cmakewebcrypto depends on itA library to invoke and build CMake projects for Dart Native Assets.