nx.js
Classes

SubtleCrypto

Implements

Methods

decrypt()

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

Decrypts some encrypted data.

It takes as arguments a key to decrypt with, some optional extra parameters, and the data to decrypt (also known as "ciphertext").

Parameters

ParameterType
algorithmAesCbcParams | AesXtsParams
keyCryptoKey
dataBufferSource

Returns

Promise<ArrayBuffer>

A Promise which will be fulfilled with the decrypted data (also known as "plaintext") as an ArrayBuffer.

Implementation of

globalThis.SubtleCrypto.decrypt

See

https://developer.mozilla.org/docs/Web/API/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): 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


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
algorithmAesCbcParams | AesXtsParams
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


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


importKey()

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

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

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.

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

Promise<CryptoKey>

Implementation of

globalThis.SubtleCrypto.importKey

See

https://developer.mozilla.org/docs/Web/API/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


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): Promise<CryptoKey>

MDN Reference

Parameters

ParameterType
formatKeyFormat
wrappedKeyBufferSource
unwrappingKeyCryptoKey
unwrapAlgorithmAesCbcParams | AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesGcmParams
unwrappedKeyAlgorithmAlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm
extractableboolean
keyUsagesKeyUsage[]

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
wrapAlgorithmAesCbcParams | AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesGcmParams

Returns

Promise<ArrayBuffer>

Implementation of

globalThis.SubtleCrypto.wrapKey

On this page