Crypto Subtle

The SubtleCrypto interface provides a number of low-level cryptographic functions. The SubtleCrypto property allows you to perform low-level cryptographic operations.

For interacting with the Web Crypto API’s low-level cryptography you can use the object SubtleCrypto.

Instance methods

This interface doesn’t inherit any methods, as it has no parent interface.

SubtleCrypto.encrypt() Returns a Promise that fulfills with the encrypted data corresponding to the clear text, algorithm, and key given as parameters.

SubtleCrypto.decrypt() Returns a Promise that fulfills with the clear data corresponding to the encrypted text, algorithm, and key given as parameters.

SubtleCrypto.sign() Returns a Promise that fulfills with the signature corresponding to the text, algorithm, and key given as parameters.

SubtleCrypto.verify() Returns a Promise that fulfills with a boolean value indicating if the signature given as a parameter matches the text, algorithm, and key that are also given as parameters.

SubtleCrypto.digest() Returns a Promise that fulfills with a digest generated from the algorithm and text given as parameters.

SubtleCrypto.generateKey() Returns a Promise that fulfills with a newly-generated CryptoKey, for symmetrical algorithms, or a CryptoKeyPair, containing two newly generated keys, for asymmetrical algorithms. These will match the algorithm, usages, and extractability given as parameters.

SubtleCrypto.deriveKey() Returns a Promise that fulfills with a newly generated CryptoKey derived from the master key and specific algorithm given as parameters.

SubtleCrypto.deriveBits() Returns a Promise that fulfills with a newly generated buffer of pseudo-random bits derived from the master key and specific algorithm given as parameters.

SubtleCrypto.importKey() Returns a Promise that fulfills with a CryptoKey corresponding to the format, the algorithm, raw key data, usages, and extractability given as parameters.

SubtleCrypto.exportKey() Returns a Promise that fulfills with the raw key data containing the key in the requested format.

SubtleCrypto.wrapKey() Returns a Promise that fulfills with a wrapped symmetric key for usage (transfer and storage) in insecure environments. The wrapped key matches the format specified in the given parameters, and wrapping is done by the given wrapping key, using the specified algorithm.

SubtleCrypto.unwrapKey() Returns a Promise that fulfills with a CryptoKey corresponding to the wrapped key given in the parameter.

For more information on SubtleCrypto visit MDN Web Docs.


Contributors