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
Parameter | Type |
---|---|
algorithm | AesCbcParams | AesXtsParams |
key | CryptoKey |
data | BufferSource |
Returns
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
>
Parameters
Parameter | Type |
---|---|
algorithm | AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params |
baseKey | CryptoKey |
length | number |
Returns
Implementation of
globalThis.SubtleCrypto.deriveBits
deriveKey()
Parameters
Parameter | Type |
---|---|
algorithm | AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params |
baseKey | CryptoKey |
derivedKeyType | AlgorithmIdentifier | HkdfParams | Pbkdf2Params | AesDerivedKeyParams | HmacImportParams |
extractable | boolean |
keyUsages | KeyUsage [] |
Returns
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
Parameter | Type | Description |
---|---|---|
algorithm | AlgorithmIdentifier | This 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" |
data | BufferSource | An ArrayBuffer , a TypedArray or a DataView object containing the data to be digested |
Returns
Implementation of
globalThis.SubtleCrypto.digest
See
https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest
encrypt()
encrypt(algorithm
, key
, data
): Promise
<ArrayBuffer
>
Parameters
Parameter | Type |
---|---|
algorithm | AesCbcParams | AesXtsParams |
key | CryptoKey |
data | BufferSource |
Returns
Implementation of
globalThis.SubtleCrypto.encrypt
exportKey()
exportKey(format, key)
exportKey(format
, key
): Promise
<JsonWebKey
>
Parameters
Parameter | Type |
---|---|
format | "jwk" |
key | CryptoKey |
Returns
Implementation of
globalThis.SubtleCrypto.exportKey
exportKey(format, key)
exportKey(format
, key
): Promise
<ArrayBuffer
>
Parameters
Parameter | Type |
---|---|
format | "pkcs8" | "raw" | "spki" |
key | CryptoKey |
Returns
Implementation of
globalThis.SubtleCrypto.exportKey
generateKey()
generateKey(algorithm, extractable, keyUsages)
generateKey(algorithm
, extractable
, keyUsages
): Promise
<CryptoKeyPair
>
Parameters
Parameter | Type |
---|---|
algorithm | "Ed25519" |
extractable | boolean |
keyUsages | readonly ("sign" | "verify" )[] |
Returns
Promise
<CryptoKeyPair
>
Implementation of
globalThis.SubtleCrypto.generateKey
generateKey(algorithm, extractable, keyUsages)
generateKey(algorithm
, extractable
, keyUsages
): Promise
<CryptoKeyPair
>
Parameters
Parameter | Type |
---|---|
algorithm | RsaHashedKeyGenParams | EcKeyGenParams |
extractable | boolean |
keyUsages | readonly KeyUsage [] |
Returns
Promise
<CryptoKeyPair
>
Implementation of
globalThis.SubtleCrypto.generateKey
generateKey(algorithm, extractable, keyUsages)
Parameters
Parameter | Type |
---|---|
algorithm | Pbkdf2Params | AesKeyGenParams | HmacKeyGenParams |
extractable | boolean |
keyUsages | readonly KeyUsage [] |
Returns
Implementation of
globalThis.SubtleCrypto.generateKey
generateKey(algorithm, extractable, keyUsages)
Parameters
Parameter | Type |
---|---|
algorithm | AlgorithmIdentifier |
extractable | boolean |
keyUsages | KeyUsage [] |
Returns
Promise
<CryptoKey
| CryptoKeyPair
>
Implementation of
globalThis.SubtleCrypto.generateKey
generateKey(algorithm, extractable, keyUsages)
generateKey(algorithm
, extractable
, keyUsages
): Promise
<CryptoKeyPair
>
Parameters
Parameter | Type |
---|---|
algorithm | RsaHashedKeyGenParams | EcKeyGenParams |
extractable | boolean |
keyUsages | readonly KeyUsage [] |
Returns
Promise
<CryptoKeyPair
>
Implementation of
globalThis.SubtleCrypto.generateKey
generateKey(algorithm, extractable, keyUsages)
Parameters
Parameter | Type |
---|---|
algorithm | Pbkdf2Params | AesKeyGenParams | HmacKeyGenParams |
extractable | boolean |
keyUsages | readonly KeyUsage [] |
Returns
Implementation of
globalThis.SubtleCrypto.generateKey
importKey()
importKey(format, keyData, algorithm, extractable, keyUsages)
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
Parameter | Type |
---|---|
format | "jwk" |
keyData | JsonWebKey |
algorithm | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm |
extractable | boolean |
keyUsages | KeyUsage [] |
Returns
Implementation of
globalThis.SubtleCrypto.importKey
See
https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey
importKey(format, keyData, algorithm, extractable, keyUsages)
Parameters
Parameter | Type |
---|---|
format | "pkcs8" | "raw" | "spki" |
keyData | BufferSource |
algorithm | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm |
extractable | boolean |
keyUsages | KeyUsage [] |
Returns
Implementation of
globalThis.SubtleCrypto.importKey
sign()
sign(algorithm
, key
, data
): Promise
<ArrayBuffer
>
Parameters
Parameter | Type |
---|---|
algorithm | AlgorithmIdentifier | RsaPssParams | EcdsaParams |
key | CryptoKey |
data | BufferSource |
Returns
Implementation of
globalThis.SubtleCrypto.sign
unwrapKey()
Parameters
Parameter | Type |
---|---|
format | KeyFormat |
wrappedKey | BufferSource |
unwrappingKey | CryptoKey |
unwrapAlgorithm | AesCbcParams | AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesGcmParams |
unwrappedKeyAlgorithm | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm |
extractable | boolean |
keyUsages | KeyUsage [] |
Returns
Implementation of
globalThis.SubtleCrypto.unwrapKey
verify()
verify(algorithm
, key
, signature
, data
): Promise
<boolean
>
Parameters
Parameter | Type |
---|---|
algorithm | AlgorithmIdentifier | RsaPssParams | EcdsaParams |
key | CryptoKey |
signature | BufferSource |
data | BufferSource |
Returns
Promise
<boolean
>
Implementation of
globalThis.SubtleCrypto.verify
wrapKey()
wrapKey(format
, key
, wrappingKey
, wrapAlgorithm
): Promise
<ArrayBuffer
>
Parameters
Parameter | Type |
---|---|
format | KeyFormat |
key | CryptoKey |
wrappingKey | CryptoKey |
wrapAlgorithm | AesCbcParams | AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesGcmParams |
Returns
Implementation of
globalThis.SubtleCrypto.wrapKey