nx.js
Classes

SubtleCrypto

Implements

Methods

decrypt()

decrypt(algorithm, key, data): Promise<ArrayBuffer>

MDN Reference

Parameters

ParameterType
algorithmAlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams
keyCryptoKey
dataBufferSource

Returns

Promise<ArrayBuffer>

Implementation of

globalThis.SubtleCrypto.decrypt


deriveBits()

deriveBits(algorithm, baseKey, length): Promise<ArrayBuffer>

MDN Reference

Parameters

ParameterType
algorithmAlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params
baseKeyCryptoKey
lengthnumber

Returns

Promise<ArrayBuffer>

Implementation of

globalThis.SubtleCrypto.deriveBits


deriveKey()

deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages)

deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

Parameters
ParameterType
algorithmAlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params
baseKeyCryptoKey
derivedKeyTypeAlgorithmIdentifier | HkdfParams | Pbkdf2Params | AesDerivedKeyParams | HmacImportParams
extractableboolean
keyUsagesKeyUsage[]
Returns

Promise<CryptoKey>

Implementation of

globalThis.SubtleCrypto.deriveKey

deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages)

deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

Parameters
ParameterType
algorithmAlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params
baseKeyCryptoKey
derivedKeyTypeAlgorithmIdentifier | HkdfParams | Pbkdf2Params | AesDerivedKeyParams | HmacImportParams
extractableboolean
keyUsagesIterable<KeyUsage, any, any>
Returns

Promise<CryptoKey>

Implementation of

globalThis.SubtleCrypto.deriveKey


digest()

digest(algorithm, data): Promise<ArrayBuffer>

Generates a digest 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.

It takes as its arguments an identifier for the digest algorithm to use and the data to digest. It returns a Promise which will be fulfilled with the digest.

Note that this API does not support streaming input: you must read the entire input into memory before passing it into the digest function.

Parameters

ParameterTypeDescription
algorithmAlgorithmIdentifierThis may be a string or an object with a single property name that is a string. The string names the hash function to use. Supported values are: - "SHA-1" (but don't use this in cryptographic applications) - "SHA-256" - "SHA-384" - "SHA-512"
dataBufferSourceAn ArrayBuffer, a TypedArray or a DataView object containing the data to be digested

Returns

Promise<ArrayBuffer>

Implementation of

globalThis.SubtleCrypto.digest

See

https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest


encrypt()

encrypt(algorithm, key, data): Promise<ArrayBuffer>

MDN Reference

Parameters

ParameterType
algorithmAlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams
keyCryptoKey
dataBufferSource

Returns

Promise<ArrayBuffer>

Implementation of

globalThis.SubtleCrypto.encrypt


exportKey()

exportKey(format, key)

exportKey(format, key): Promise<JsonWebKey>

MDN Reference

Parameters
ParameterType
format"jwk"
keyCryptoKey
Returns

Promise<JsonWebKey>

Implementation of

globalThis.SubtleCrypto.exportKey

exportKey(format, key)

exportKey(format, key): Promise<ArrayBuffer>

MDN Reference

Parameters
ParameterType
format"pkcs8" | "raw" | "spki"
keyCryptoKey
Returns

Promise<ArrayBuffer>

Implementation of

globalThis.SubtleCrypto.exportKey

exportKey(format, key)

exportKey(format, key): Promise<ArrayBuffer | JsonWebKey>

MDN Reference

Parameters
ParameterType
formatKeyFormat
keyCryptoKey
Returns

Promise<ArrayBuffer | JsonWebKey>

Implementation of

globalThis.SubtleCrypto.exportKey


generateKey()

generateKey(algorithm, extractable, keyUsages)

generateKey(algorithm, extractable, keyUsages): Promise<CryptoKeyPair>

MDN Reference

Parameters
ParameterType
algorithm"Ed25519"
extractableboolean
keyUsagesreadonly ("sign" | "verify")[]
Returns

Promise<CryptoKeyPair>

Implementation of

globalThis.SubtleCrypto.generateKey

generateKey(algorithm, extractable, keyUsages)

generateKey(algorithm, extractable, keyUsages): Promise<CryptoKeyPair>

MDN Reference

Parameters
ParameterType
algorithmRsaHashedKeyGenParams | EcKeyGenParams
extractableboolean
keyUsagesreadonly KeyUsage[]
Returns

Promise<CryptoKeyPair>

Implementation of

globalThis.SubtleCrypto.generateKey

generateKey(algorithm, extractable, keyUsages)

generateKey(algorithm, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

Parameters
ParameterType
algorithmPbkdf2Params | AesKeyGenParams | HmacKeyGenParams
extractableboolean
keyUsagesreadonly KeyUsage[]
Returns

Promise<CryptoKey>

Implementation of

globalThis.SubtleCrypto.generateKey

generateKey(algorithm, extractable, keyUsages)

generateKey(algorithm, extractable, keyUsages): Promise<CryptoKey | CryptoKeyPair>

MDN Reference

Parameters
ParameterType
algorithmAlgorithmIdentifier
extractableboolean
keyUsagesKeyUsage[]
Returns

Promise<CryptoKey | CryptoKeyPair>

Implementation of

globalThis.SubtleCrypto.generateKey

generateKey(algorithm, extractable, keyUsages)

generateKey(algorithm, extractable, keyUsages): Promise<CryptoKeyPair>

MDN Reference

Parameters
ParameterType
algorithmRsaHashedKeyGenParams | EcKeyGenParams
extractableboolean
keyUsagesreadonly KeyUsage[]
Returns

Promise<CryptoKeyPair>

Implementation of

globalThis.SubtleCrypto.generateKey

generateKey(algorithm, extractable, keyUsages)

generateKey(algorithm, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

Parameters
ParameterType
algorithmPbkdf2Params | AesKeyGenParams | HmacKeyGenParams
extractableboolean
keyUsagesreadonly KeyUsage[]
Returns

Promise<CryptoKey>

Implementation of

globalThis.SubtleCrypto.generateKey

generateKey(algorithm, extractable, keyUsages)

generateKey(algorithm, extractable, keyUsages): Promise<CryptoKey | CryptoKeyPair>

MDN Reference

Parameters
ParameterType
algorithmAlgorithmIdentifier
extractableboolean
keyUsagesIterable<KeyUsage, any, any>
Returns

Promise<CryptoKey | CryptoKeyPair>

Implementation of

globalThis.SubtleCrypto.generateKey


importKey()

importKey(format, keyData, algorithm, extractable, keyUsages)

importKey(format, keyData, algorithm, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

Parameters
ParameterType
format"jwk"
keyDataJsonWebKey
algorithmAlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm
extractableboolean
keyUsagesreadonly KeyUsage[]
Returns

Promise<CryptoKey>

Implementation of

globalThis.SubtleCrypto.importKey

importKey(format, keyData, algorithm, extractable, keyUsages)

importKey(format, keyData, algorithm, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

Parameters
ParameterType
format"pkcs8" | "raw" | "spki"
keyDataBufferSource
algorithmAlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm
extractableboolean
keyUsagesKeyUsage[]
Returns

Promise<CryptoKey>

Implementation of

globalThis.SubtleCrypto.importKey

importKey(format, keyData, algorithm, extractable, keyUsages)

importKey(format, keyData, algorithm, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

Parameters
ParameterType
format"jwk"
keyDataJsonWebKey
algorithmAlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm
extractableboolean
keyUsagesreadonly KeyUsage[]
Returns

Promise<CryptoKey>

Implementation of

globalThis.SubtleCrypto.importKey

importKey(format, keyData, algorithm, extractable, keyUsages)

importKey(format, keyData, algorithm, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

Parameters
ParameterType
format"pkcs8" | "raw" | "spki"
keyDataBufferSource
algorithmAlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm
extractableboolean
keyUsagesIterable<KeyUsage, any, any>
Returns

Promise<CryptoKey>

Implementation of

globalThis.SubtleCrypto.importKey


sign()

sign(algorithm, key, data): Promise<ArrayBuffer>

MDN Reference

Parameters

ParameterType
algorithmAlgorithmIdentifier | RsaPssParams | EcdsaParams
keyCryptoKey
dataBufferSource

Returns

Promise<ArrayBuffer>

Implementation of

globalThis.SubtleCrypto.sign


unwrapKey()

unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)

unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

Parameters
ParameterType
formatKeyFormat
wrappedKeyBufferSource
unwrappingKeyCryptoKey
unwrapAlgorithmAlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams
unwrappedKeyAlgorithmAlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm
extractableboolean
keyUsagesKeyUsage[]
Returns

Promise<CryptoKey>

Implementation of

globalThis.SubtleCrypto.unwrapKey

unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)

unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages): Promise<CryptoKey>

MDN Reference

Parameters
ParameterType
formatKeyFormat
wrappedKeyBufferSource
unwrappingKeyCryptoKey
unwrapAlgorithmAlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams
unwrappedKeyAlgorithmAlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm
extractableboolean
keyUsagesIterable<KeyUsage, any, any>
Returns

Promise<CryptoKey>

Implementation of

globalThis.SubtleCrypto.unwrapKey


verify()

verify(algorithm, key, signature, data): Promise<boolean>

MDN Reference

Parameters

ParameterType
algorithmAlgorithmIdentifier | RsaPssParams | EcdsaParams
keyCryptoKey
signatureBufferSource
dataBufferSource

Returns

Promise<boolean>

Implementation of

globalThis.SubtleCrypto.verify


wrapKey()

wrapKey(format, key, wrappingKey, wrapAlgorithm): Promise<ArrayBuffer>

MDN Reference

Parameters

ParameterType
formatKeyFormat
keyCryptoKey
wrappingKeyCryptoKey
wrapAlgorithmAlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams

Returns

Promise<ArrayBuffer>

Implementation of

globalThis.SubtleCrypto.wrapKey

On this page