SubtleCrypto extension type

The SubtleCrypto interface of the Web Crypto API provides a number of low-level cryptographic functions. Access to the features of SubtleCrypto is obtained through the Crypto.subtle property of the Crypto object you get from the crypto_property property.

Warning: This API provides a number of low-level cryptographic primitives. It's very easy to misuse them, and the pitfalls involved can be very subtle.

Even assuming you use the basic cryptographic functions correctly, secure key management and overall security system design are extremely hard to get right, and are generally the domain of specialist security experts.

Errors in security system design and implementation can make the security of the system completely ineffective.

Please learn and experiment, but don't guarantee or imply the security of your work before an individual knowledgeable in this subject matter thoroughly reviews it. The Crypto 101 Course can be a great place to start learning about the design and implementation of secure systems.

on
Implemented types

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

decrypt(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data) JSPromise<JSAny?>
The decrypt() method of the SubtleCrypto interface decrypts some encrypted data. It takes as arguments a to decrypt with, some optional extra parameters, and the data to decrypt (also known as "ciphertext"). It returns a Promise which will be fulfilled with the decrypted data (also known as "plaintext").
deriveBits(AlgorithmIdentifier algorithm, CryptoKey baseKey, int length) JSPromise<JSArrayBuffer>
The deriveBits() method of the SubtleCrypto interface can be used to derive an array of bits from a base key.
deriveKey(AlgorithmIdentifier algorithm, CryptoKey baseKey, AlgorithmIdentifier derivedKeyType, bool extractable, JSArray<JSString> keyUsages) JSPromise<JSAny?>
The deriveKey() method of the SubtleCrypto interface can be used to derive a secret key from a master key.
digest(AlgorithmIdentifier algorithm, BufferSource data) JSPromise<JSAny?>
The digest() method of the SubtleCrypto interface generates a of the given data. A digest is a short fixed-length value derived from some variable-length input. Cryptographic digests should exhibit collision-resistance, meaning that it's hard to come up with two different inputs that have the same digest value.
encrypt(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data) JSPromise<JSAny?>
The encrypt() method of the SubtleCrypto interface encrypts data.
exportKey(KeyFormat format, CryptoKey key) JSPromise<JSAny?>
The exportKey() method of the SubtleCrypto interface exports a key: that is, it takes as input a CryptoKey object and gives you the key in an external, portable format.
generateKey(AlgorithmIdentifier algorithm, bool extractable, JSArray<JSString> keyUsages) JSPromise<JSAny?>
Use the generateKey() method of the SubtleCrypto interface to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms).
importKey(KeyFormat format, JSObject keyData, AlgorithmIdentifier algorithm, bool extractable, JSArray<JSString> keyUsages) JSPromise<CryptoKey>
The importKey() method of the SubtleCrypto interface imports a key: that is, it takes as input a key in an external, portable format and gives you a CryptoKey object that you can use in the Web Crypto API.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sign(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource data) JSPromise<JSAny?>
The sign() method of the SubtleCrypto interface generates a digital .
toString() String
A string representation of this object.
inherited
unwrapKey(KeyFormat format, BufferSource wrappedKey, CryptoKey unwrappingKey, AlgorithmIdentifier unwrapAlgorithm, AlgorithmIdentifier unwrappedKeyAlgorithm, bool extractable, JSArray<JSString> keyUsages) JSPromise<CryptoKey>
The unwrapKey() method of the SubtleCrypto interface "unwraps" a key. This means that it takes as its input a key that has been exported and then encrypted (also called "wrapped"). It decrypts the key and then imports it, returning a CryptoKey object that can be used in the Web Crypto API.
verify(AlgorithmIdentifier algorithm, CryptoKey key, BufferSource signature, BufferSource data) JSPromise<JSAny?>
The verify() method of the SubtleCrypto interface verifies a digital .
wrapKey(KeyFormat format, CryptoKey key, CryptoKey wrappingKey, AlgorithmIdentifier wrapAlgorithm) JSPromise<JSAny?>
The wrapKey() method of the SubtleCrypto interface "wraps" a key. This means that it exports the key in an external, portable format, then encrypts the exported key. Wrapping a key helps protect it in untrusted environments, such as inside an otherwise unprotected data store or in transmission over an unprotected network.

Operators

operator ==(Object other) bool
The equality operator.
inherited