Interface SubtleCrypto
interface SubtleCrypto {
decrypt(algorithm:
| AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
deriveBits(algorithm:
| EcdhKeyDeriveParams
| AlgorithmIdentifier
| HkdfParams
| Pbkdf2Params, baseKey: CryptoKey, length: number): Promise<ArrayBuffer>;
deriveKey(algorithm:
| EcdhKeyDeriveParams
| AlgorithmIdentifier
| HkdfParams
| Pbkdf2Params, baseKey: CryptoKey, derivedKeyType:
| AesDerivedKeyParams
| AlgorithmIdentifier
| HkdfParams
| HmacImportParams
| Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
deriveKey(algorithm:
| EcdhKeyDeriveParams
| AlgorithmIdentifier
| HkdfParams
| Pbkdf2Params, baseKey: CryptoKey, derivedKeyType:
| AesDerivedKeyParams
| AlgorithmIdentifier
| HkdfParams
| HmacImportParams
| Pbkdf2Params, extractable: boolean, keyUsages: Iterable<KeyUsage, any, any>): Promise<CryptoKey>;
digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer>;
encrypt(algorithm:
| AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
exportKey(format: "raw" | "pkcs8" | "spki", key: CryptoKey): Promise<ArrayBuffer>;
exportKey(format: KeyFormat, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
generateKey(algorithm: "Ed25519", extractable: boolean, keyUsages: readonly ("sign" | "verify")[]): Promise<CryptoKeyPair>;
generateKey(algorithm: EcKeyGenParams | RsaHashedKeyGenParams, extractable: boolean, keyUsages: readonly KeyUsage[]): Promise<CryptoKeyPair>;
generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: readonly KeyUsage[]): Promise<CryptoKey>;
generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey | CryptoKeyPair>;
generateKey(algorithm: "Ed25519", extractable: boolean, keyUsages: readonly ("sign" | "verify")[]): Promise<CryptoKeyPair>;
generateKey(algorithm: EcKeyGenParams | RsaHashedKeyGenParams, extractable: boolean, keyUsages: readonly KeyUsage[]): Promise<CryptoKeyPair>;
generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: readonly KeyUsage[]): Promise<CryptoKey>;
generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: Iterable<KeyUsage, any, any>): Promise<CryptoKey | CryptoKeyPair>;
importKey(format: "jwk", keyData: JsonWebKey, algorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams, extractable: boolean, keyUsages: readonly KeyUsage[]): Promise<CryptoKey>;
importKey(format: "raw" | "pkcs8" | "spki", keyData: BufferSource, algorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
importKey(format: "jwk", keyData: JsonWebKey, algorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams, extractable: boolean, keyUsages: readonly KeyUsage[]): Promise<CryptoKey>;
importKey(format: "raw" | "pkcs8" | "spki", keyData: BufferSource, algorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams, extractable: boolean, keyUsages: Iterable<KeyUsage, any, any>): Promise<CryptoKey>;
sign(algorithm: EcdsaParams | AlgorithmIdentifier | RsaPssParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm:
| AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams, unwrappedKeyAlgorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm:
| AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams, unwrappedKeyAlgorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams, extractable: boolean, keyUsages: Iterable<KeyUsage, any, any>): Promise<CryptoKey>;
verify(algorithm: EcdsaParams | AlgorithmIdentifier | RsaPssParams, key: CryptoKey, signature: BufferSource, data: BufferSource): Promise<boolean>;
wrapKey(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm:
| AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams): Promise<ArrayBuffer>;
}
decrypt(algorithm:
| AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
deriveBits(algorithm:
| EcdhKeyDeriveParams
| AlgorithmIdentifier
| HkdfParams
| Pbkdf2Params, baseKey: CryptoKey, length: number): Promise<ArrayBuffer>;
deriveKey(algorithm:
| EcdhKeyDeriveParams
| AlgorithmIdentifier
| HkdfParams
| Pbkdf2Params, baseKey: CryptoKey, derivedKeyType:
| AesDerivedKeyParams
| AlgorithmIdentifier
| HkdfParams
| HmacImportParams
| Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
deriveKey(algorithm:
| EcdhKeyDeriveParams
| AlgorithmIdentifier
| HkdfParams
| Pbkdf2Params, baseKey: CryptoKey, derivedKeyType:
| AesDerivedKeyParams
| AlgorithmIdentifier
| HkdfParams
| HmacImportParams
| Pbkdf2Params, extractable: boolean, keyUsages: Iterable<KeyUsage, any, any>): Promise<CryptoKey>;
digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise<ArrayBuffer>;
encrypt(algorithm:
| AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
exportKey(format: "raw" | "pkcs8" | "spki", key: CryptoKey): Promise<ArrayBuffer>;
exportKey(format: KeyFormat, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
generateKey(algorithm: "Ed25519", extractable: boolean, keyUsages: readonly ("sign" | "verify")[]): Promise<CryptoKeyPair>;
generateKey(algorithm: EcKeyGenParams | RsaHashedKeyGenParams, extractable: boolean, keyUsages: readonly KeyUsage[]): Promise<CryptoKeyPair>;
generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: readonly KeyUsage[]): Promise<CryptoKey>;
generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey | CryptoKeyPair>;
generateKey(algorithm: "Ed25519", extractable: boolean, keyUsages: readonly ("sign" | "verify")[]): Promise<CryptoKeyPair>;
generateKey(algorithm: EcKeyGenParams | RsaHashedKeyGenParams, extractable: boolean, keyUsages: readonly KeyUsage[]): Promise<CryptoKeyPair>;
generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: readonly KeyUsage[]): Promise<CryptoKey>;
generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: Iterable<KeyUsage, any, any>): Promise<CryptoKey | CryptoKeyPair>;
importKey(format: "jwk", keyData: JsonWebKey, algorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams, extractable: boolean, keyUsages: readonly KeyUsage[]): Promise<CryptoKey>;
importKey(format: "raw" | "pkcs8" | "spki", keyData: BufferSource, algorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
importKey(format: "jwk", keyData: JsonWebKey, algorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams, extractable: boolean, keyUsages: readonly KeyUsage[]): Promise<CryptoKey>;
importKey(format: "raw" | "pkcs8" | "spki", keyData: BufferSource, algorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams, extractable: boolean, keyUsages: Iterable<KeyUsage, any, any>): Promise<CryptoKey>;
sign(algorithm: EcdsaParams | AlgorithmIdentifier | RsaPssParams, key: CryptoKey, data: BufferSource): Promise<ArrayBuffer>;
unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm:
| AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams, unwrappedKeyAlgorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams, extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKey>;
unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm:
| AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams, unwrappedKeyAlgorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams, extractable: boolean, keyUsages: Iterable<KeyUsage, any, any>): Promise<CryptoKey>;
verify(algorithm: EcdsaParams | AlgorithmIdentifier | RsaPssParams, key: CryptoKey, signature: BufferSource, data: BufferSource): Promise<boolean>;
wrapKey(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm:
| AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams): Promise<ArrayBuffer>;
}
Methods
decrypt
- decrypt(algorithm, key, data): Promise<ArrayBuffer>
Parameters
- algorithm:
| AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams - key: CryptoKey
- data: BufferSource
Returns Promise<ArrayBuffer>
- algorithm:
deriveBits
- derive
Bits (algorithm, baseKey, length): Promise<ArrayBuffer> Parameters
- algorithm:
| EcdhKeyDeriveParams
| AlgorithmIdentifier
| HkdfParams
| Pbkdf2Params - baseKey: CryptoKey
- length: number
Returns Promise<ArrayBuffer>
- algorithm:
deriveKey
- derive
Key (algorithm, baseKey, derivedKeyType, extractable, keyUsages): Promise<CryptoKey> Parameters
- algorithm:
| EcdhKeyDeriveParams
| AlgorithmIdentifier
| HkdfParams
| Pbkdf2Params - baseKey: CryptoKey
- derivedKeyType:
| AesDerivedKeyParams
| AlgorithmIdentifier
| HkdfParams
| HmacImportParams
| Pbkdf2Params - extractable: boolean
- keyUsages: KeyUsage[]
Returns Promise<CryptoKey>
- algorithm:
- derive
Key (algorithm, baseKey, derivedKeyType, extractable, keyUsages): Promise<CryptoKey> Parameters
- algorithm:
| EcdhKeyDeriveParams
| AlgorithmIdentifier
| HkdfParams
| Pbkdf2Params - baseKey: CryptoKey
- derivedKeyType:
| AesDerivedKeyParams
| AlgorithmIdentifier
| HkdfParams
| HmacImportParams
| Pbkdf2Params - extractable: boolean
- keyUsages: Iterable<KeyUsage, any, any>
Returns Promise<CryptoKey>
- algorithm:
digest
- digest(algorithm, data): Promise<ArrayBuffer>
Parameters
- algorithm: AlgorithmIdentifier
- data: BufferSource
Returns Promise<ArrayBuffer>
encrypt
- encrypt(algorithm, key, data): Promise<ArrayBuffer>
Parameters
- algorithm:
| AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams - key: CryptoKey
- data: BufferSource
Returns Promise<ArrayBuffer>
- algorithm:
exportKey
- export
Key (format, key): Promise<JsonWebKey> Parameters
- format: "jwk"
- key: CryptoKey
Returns Promise<JsonWebKey>
- export
Key (format, key): Promise<ArrayBuffer> Parameters
- format: "raw" | "pkcs8" | "spki"
- key: CryptoKey
Returns Promise<ArrayBuffer>
- export
Key (format, key): Promise<ArrayBuffer | JsonWebKey> Returns Promise<ArrayBuffer | JsonWebKey>
generateKey
- generate
Key (algorithm, extractable, keyUsages): Promise<CryptoKeyPair> Parameters
- algorithm: "Ed25519"
- extractable: boolean
- keyUsages: readonly ("sign" | "verify")[]
Returns Promise<CryptoKeyPair>
- generate
Key (algorithm, extractable, keyUsages): Promise<CryptoKeyPair> Parameters
- algorithm: EcKeyGenParams | RsaHashedKeyGenParams
- extractable: boolean
- keyUsages: readonly KeyUsage[]
Returns Promise<CryptoKeyPair>
- generate
Key (algorithm, extractable, keyUsages): Promise<CryptoKey> Parameters
- algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params
- extractable: boolean
- keyUsages: readonly KeyUsage[]
Returns Promise<CryptoKey>
- generate
Key (algorithm, extractable, keyUsages): Promise<CryptoKey | CryptoKeyPair> Parameters
- algorithm: AlgorithmIdentifier
- extractable: boolean
- keyUsages: KeyUsage[]
Returns Promise<CryptoKey | CryptoKeyPair>
- generate
Key (algorithm, extractable, keyUsages): Promise<CryptoKeyPair> Parameters
- algorithm: "Ed25519"
- extractable: boolean
- keyUsages: readonly ("sign" | "verify")[]
Returns Promise<CryptoKeyPair>
- generate
Key (algorithm, extractable, keyUsages): Promise<CryptoKeyPair> Parameters
- algorithm: EcKeyGenParams | RsaHashedKeyGenParams
- extractable: boolean
- keyUsages: readonly KeyUsage[]
Returns Promise<CryptoKeyPair>
- generate
Key (algorithm, extractable, keyUsages): Promise<CryptoKey> Parameters
- algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params
- extractable: boolean
- keyUsages: readonly KeyUsage[]
Returns Promise<CryptoKey>
- generate
Key (algorithm, extractable, keyUsages): Promise<CryptoKey | CryptoKeyPair> Parameters
- algorithm: AlgorithmIdentifier
- extractable: boolean
- keyUsages: Iterable<KeyUsage, any, any>
Returns Promise<CryptoKey | CryptoKeyPair>
importKey
- import
Key (format, keyData, algorithm, extractable, keyUsages): Promise<CryptoKey> Parameters
- format: "jwk"
- keyData: JsonWebKey
- algorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams - extractable: boolean
- keyUsages: readonly KeyUsage[]
Returns Promise<CryptoKey>
- import
Key (format, keyData, algorithm, extractable, keyUsages): Promise<CryptoKey> Parameters
- format: "raw" | "pkcs8" | "spki"
- keyData: BufferSource
- algorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams - extractable: boolean
- keyUsages: KeyUsage[]
Returns Promise<CryptoKey>
- import
Key (format, keyData, algorithm, extractable, keyUsages): Promise<CryptoKey> Parameters
- format: "jwk"
- keyData: JsonWebKey
- algorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams - extractable: boolean
- keyUsages: readonly KeyUsage[]
Returns Promise<CryptoKey>
- import
Key (format, keyData, algorithm, extractable, keyUsages): Promise<CryptoKey> Parameters
- format: "raw" | "pkcs8" | "spki"
- keyData: BufferSource
- algorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams - extractable: boolean
- keyUsages: Iterable<KeyUsage, any, any>
Returns Promise<CryptoKey>
sign
- sign(algorithm, key, data): Promise<ArrayBuffer>
Parameters
- algorithm: EcdsaParams | AlgorithmIdentifier | RsaPssParams
- key: CryptoKey
- data: BufferSource
Returns Promise<ArrayBuffer>
unwrapKey
- unwrap
Key (format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages): Promise<CryptoKey> Parameters
- format: KeyFormat
- wrappedKey: BufferSource
- unwrappingKey: CryptoKey
- unwrapAlgorithm:
| AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams - unwrappedKeyAlgorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams - extractable: boolean
- keyUsages: KeyUsage[]
Returns Promise<CryptoKey>
- unwrap
Key (format, wrappedKey, unwrappingKey, unwrapAlgorithm, unwrappedKeyAlgorithm, extractable, keyUsages): Promise<CryptoKey> Parameters
- format: KeyFormat
- wrappedKey: BufferSource
- unwrappingKey: CryptoKey
- unwrapAlgorithm:
| AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams - unwrappedKeyAlgorithm:
| AesKeyAlgorithm
| AlgorithmIdentifier
| EcKeyImportParams
| HmacImportParams
| RsaHashedImportParams - extractable: boolean
- keyUsages: Iterable<KeyUsage, any, any>
Returns Promise<CryptoKey>
verify
- verify(algorithm, key, signature, data): Promise<boolean>
Parameters
- algorithm: EcdsaParams | AlgorithmIdentifier | RsaPssParams
- key: CryptoKey
- signature: BufferSource
- data: BufferSource
Returns Promise<boolean>
wrapKey
- wrap
Key (format, key, wrappingKey, wrapAlgorithm): Promise<ArrayBuffer> Parameters
- format: KeyFormat
- key: CryptoKey
- wrappingKey: CryptoKey
- wrapAlgorithm:
| AesCbcParams
| AesCtrParams
| AesGcmParams
| AlgorithmIdentifier
| RsaOaepParams
Returns Promise<ArrayBuffer>
MDN Reference