SubtleCrypto
Implements
Methods
decrypt()
decrypt(algorithm
, key
, data
): Promise
<ArrayBuffer
>
Parameters
Parameter | Type |
---|---|
algorithm | AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams |
key | CryptoKey |
data | BufferSource |
Returns
Implementation of
globalThis.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()
deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages)
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
deriveKey(algorithm, baseKey, derivedKeyType, extractable, keyUsages)
Parameters
Parameter | Type |
---|---|
algorithm | AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params |
baseKey | CryptoKey |
derivedKeyType | AlgorithmIdentifier | HkdfParams | Pbkdf2Params | AesDerivedKeyParams | HmacImportParams |
extractable | boolean |
keyUsages | Iterable <KeyUsage , any , any > |
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 | AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams |
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
Promise
<JsonWebKey
>
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
exportKey(format, key)
exportKey(format
, key
): Promise
<ArrayBuffer
| JsonWebKey
>
Parameters
Parameter | Type |
---|---|
format | KeyFormat |
key | CryptoKey |
Returns
Promise
<ArrayBuffer
| JsonWebKey
>
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
generateKey(algorithm, extractable, keyUsages)
Parameters
Parameter | Type |
---|---|
algorithm | AlgorithmIdentifier |
extractable | boolean |
keyUsages | Iterable <KeyUsage , any , any > |
Returns
Promise
<CryptoKey
| CryptoKeyPair
>
Implementation of
globalThis.SubtleCrypto.generateKey
importKey()
importKey(format, keyData, algorithm, extractable, keyUsages)
Parameters
Parameter | Type |
---|---|
format | "jwk" |
keyData | JsonWebKey |
algorithm | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm |
extractable | boolean |
keyUsages | readonly KeyUsage [] |
Returns
Implementation of
globalThis.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
importKey(format, keyData, algorithm, extractable, keyUsages)
Parameters
Parameter | Type |
---|---|
format | "jwk" |
keyData | JsonWebKey |
algorithm | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm |
extractable | boolean |
keyUsages | readonly KeyUsage [] |
Returns
Implementation of
globalThis.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 | Iterable <KeyUsage , any , any > |
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()
unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)
Parameters
Parameter | Type |
---|---|
format | KeyFormat |
wrappedKey | BufferSource |
unwrappingKey | CryptoKey |
unwrapAlgorithm | AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams |
unwrappedKeyAlgorithm | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm |
extractable | boolean |
keyUsages | KeyUsage [] |
Returns
Implementation of
globalThis.SubtleCrypto.unwrapKey
unwrapKey(format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages)
Parameters
Parameter | Type |
---|---|
format | KeyFormat |
wrappedKey | BufferSource |
unwrappingKey | CryptoKey |
unwrapAlgorithm | AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams |
unwrappedKeyAlgorithm | AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm |
extractable | boolean |
keyUsages | Iterable <KeyUsage , any , any > |
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 | AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams |
Returns
Implementation of
globalThis.SubtleCrypto.wrapKey