Cross-platform implementation of Web Cryptography APIs
116
stars
334
commits
Dart
primary language
Sep 10, 2026
updated
This package provides a cross-platform implementation of the Web Cryptography API.
Disclaimer: This is not an officially supported Google product.
This packages provides an implementation of the
Web Cryptography API across multiple platforms. Outside the
browser, this package features a native implementation embedding
BoringSSL using dart:ffi. When used inside a
web browser this package wraps the window.crypto APIs and
providing the same Dart API as the native implementation.
This way, package:webcrypto provides the same crypto API on Android, iOS, Web, Windows, Linux and Mac.
Example
import 'dart:convert' show base64, utf8;
import 'package:webcrypto/webcrypto.dart';
Future<void> main() async {
final digest = await Hash.sha256.digestBytes(utf8.encode('Hello World'));
print(base.encode(digest));
}
Features:
Missing:
For a discussion of the API design of this package,
see doc/design-rationale-md.
When you have a dependency on package:webcrypto, it will use
hooks to build BoringSSL. Thus, your system
must have:
cmake, and,gcc or clang)This package has a few limitations compared to the
Web Cryptography API. For a discussion of parity with
Web Cryptography APIs see doc/webcrypto-parity.md.
deriveKey is not supported, however, keys can always be created from
derivedBits which is supported.wrapKey is not supported, however, keys can be exported and encrypted.unwrapKey is not supported, however, keys can be decrypted and imported.AES-KW is not supported because it does not support encrypt/decrypt.This package has many tests cases to asses compatibility across the native implementation using BoringSSL and various browser implementations of the Web Cryptography APIs.
At the moment compatibility testing is limited to native implementation, Chrome, Firefox and Safari.
Known Issues:
AES-CTR.window.crypto does not expose a streaming API. However, the native
implementation using BoringSSL does support streaming.window.crypto.subtle require a secure
context. When loaded from an insecure context, package:webcrypto throws
UnsupportedError for those operations with guidance to use HTTPS or a
trustworthy local origin such as localhost. fillRandomBytes() continues
to work because it uses window.crypto.getRandomValues(), which browsers
expose outside secure contexts.Dart
92.2%
CMake
2.5%
C++
2.5%
Shell
2.0%
Cross-platform implementation of Web Cryptography APIs
116
stars
334
commits
Dart
primary language
Sep 10, 2026
updated
This package provides a cross-platform implementation of the Web Cryptography API.
Disclaimer: This is not an officially supported Google product.
This packages provides an implementation of the
Web Cryptography API across multiple platforms. Outside the
browser, this package features a native implementation embedding
BoringSSL using dart:ffi. When used inside a
web browser this package wraps the window.crypto APIs and
providing the same Dart API as the native implementation.
This way, package:webcrypto provides the same crypto API on Android, iOS, Web, Windows, Linux and Mac.
Example
import 'dart:convert' show base64, utf8;
import 'package:webcrypto/webcrypto.dart';
Future<void> main() async {
final digest = await Hash.sha256.digestBytes(utf8.encode('Hello World'));
print(base.encode(digest));
}
Features:
Missing:
For a discussion of the API design of this package,
see doc/design-rationale-md.
When you have a dependency on package:webcrypto, it will use
hooks to build BoringSSL. Thus, your system
must have:
cmake, and,gcc or clang)This package has a few limitations compared to the
Web Cryptography API. For a discussion of parity with
Web Cryptography APIs see doc/webcrypto-parity.md.
deriveKey is not supported, however, keys can always be created from
derivedBits which is supported.wrapKey is not supported, however, keys can be exported and encrypted.unwrapKey is not supported, however, keys can be decrypted and imported.AES-KW is not supported because it does not support encrypt/decrypt.This package has many tests cases to asses compatibility across the native implementation using BoringSSL and various browser implementations of the Web Cryptography APIs.
At the moment compatibility testing is limited to native implementation, Chrome, Firefox and Safari.
Known Issues:
AES-CTR.window.crypto does not expose a streaming API. However, the native
implementation using BoringSSL does support streaming.window.crypto.subtle require a secure
context. When loaded from an insecure context, package:webcrypto throws
UnsupportedError for those operations with guidance to use HTTPS or a
trustworthy local origin such as localhost. fillRandomBytes() continues
to work because it uses window.crypto.getRandomValues(), which browsers
expose outside secure contexts.Dart
92.2%
CMake
2.5%
C++
2.5%
Shell
2.0%