SubtleCrypto
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1185
The SubtleCrypto interface of the Web Crypto API provides a number of low-level cryptographic functions.
Available only in secure contexts.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new SubtleCrypto():
SubtleCrypto
Returns
Section titled “Returns”SubtleCrypto
Methods
Section titled “Methods”decrypt()
Section titled “decrypt()”decrypt(
algorithm,key,cipherText):Promise<ArrayBuffer>
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1201
The decrypt() method of the SubtleCrypto interface decrypts some encrypted data.
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”string | SubtleCryptoEncryptAlgorithm
cipherText
Section titled “cipherText”ArrayBuffer | ArrayBufferView<ArrayBufferLike>
Returns
Section titled “Returns”Promise<ArrayBuffer>
deriveBits()
Section titled “deriveBits()”deriveBits(
algorithm,baseKey,length?):Promise<ArrayBuffer>
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1263
The deriveBits() method of the key.
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”string | SubtleCryptoDeriveKeyAlgorithm
baseKey
Section titled “baseKey”length?
Section titled “length?”null | number
Returns
Section titled “Returns”Promise<ArrayBuffer>
deriveKey()
Section titled “deriveKey()”deriveKey(
algorithm,baseKey,derivedKeyAlgorithm,extractable,keyUsages):Promise<CryptoKey>
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1251
The deriveKey() method of the SubtleCrypto interface can be used to derive a secret key from a master key.
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”string | SubtleCryptoDeriveKeyAlgorithm
baseKey
Section titled “baseKey”derivedKeyAlgorithm
Section titled “derivedKeyAlgorithm”string | SubtleCryptoImportKeyAlgorithm
extractable
Section titled “extractable”boolean
keyUsages
Section titled “keyUsages”string[]
Returns
Section titled “Returns”Promise<CryptoKey>
digest()
Section titled “digest()”digest(
algorithm,data):Promise<ArrayBuffer>
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1232
The digest() method of the SubtleCrypto interface generates a digest of the given data, using the specified hash function.
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”string | SubtleCryptoHashAlgorithm
ArrayBuffer | ArrayBufferView<ArrayBufferLike>
Returns
Section titled “Returns”Promise<ArrayBuffer>
encrypt()
Section titled “encrypt()”encrypt(
algorithm,key,plainText):Promise<ArrayBuffer>
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1191
The encrypt() method of the SubtleCrypto interface encrypts data.
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”string | SubtleCryptoEncryptAlgorithm
plainText
Section titled “plainText”ArrayBuffer | ArrayBufferView<ArrayBufferLike>
Returns
Section titled “Returns”Promise<ArrayBuffer>
exportKey()
Section titled “exportKey()”exportKey(
format,key):Promise<ArrayBuffer|JsonWebKey>
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1285
The exportKey() method of the SubtleCrypto interface exports a key: that is, it takes as input a CryptoKey object and gives you the key in an external, portable format.
Parameters
Section titled “Parameters”format
Section titled “format”string
Returns
Section titled “Returns”Promise<ArrayBuffer | JsonWebKey>
generateKey()
Section titled “generateKey()”generateKey(
algorithm,extractable,keyUsages):Promise<CryptoKey|CryptoKeyPair>
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1241
The generateKey() method of the SubtleCrypto interface is used to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms).
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”string | SubtleCryptoGenerateKeyAlgorithm
extractable
Section titled “extractable”boolean
keyUsages
Section titled “keyUsages”string[]
Returns
Section titled “Returns”Promise<CryptoKey | CryptoKeyPair>
importKey()
Section titled “importKey()”importKey(
format,keyData,algorithm,extractable,keyUsages):Promise<CryptoKey>
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1273
The importKey() method of the SubtleCrypto interface imports a key: that is, it 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
Section titled “Parameters”format
Section titled “format”string
keyData
Section titled “keyData”ArrayBuffer | ArrayBufferView<ArrayBufferLike> | JsonWebKey
algorithm
Section titled “algorithm”string | SubtleCryptoImportKeyAlgorithm
extractable
Section titled “extractable”boolean
keyUsages
Section titled “keyUsages”string[]
Returns
Section titled “Returns”Promise<CryptoKey>
sign()
Section titled “sign()”sign(
algorithm,key,data):Promise<ArrayBuffer>
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1211
The sign() method of the SubtleCrypto interface generates a digital signature.
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”string | SubtleCryptoSignAlgorithm
ArrayBuffer | ArrayBufferView<ArrayBufferLike>
Returns
Section titled “Returns”Promise<ArrayBuffer>
timingSafeEqual()
Section titled “timingSafeEqual()”timingSafeEqual(
a,b):boolean
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1311
Parameters
Section titled “Parameters”ArrayBuffer | ArrayBufferView<ArrayBufferLike>
ArrayBuffer | ArrayBufferView<ArrayBufferLike>
Returns
Section titled “Returns”boolean
unwrapKey()
Section titled “unwrapKey()”unwrapKey(
format,wrappedKey,unwrappingKey,unwrapAlgorithm,unwrappedKeyAlgorithm,extractable,keyUsages):Promise<CryptoKey>
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1302
The unwrapKey() method of the SubtleCrypto interface ‘unwraps’ a key.
Parameters
Section titled “Parameters”format
Section titled “format”string
wrappedKey
Section titled “wrappedKey”ArrayBuffer | ArrayBufferView<ArrayBufferLike>
unwrappingKey
Section titled “unwrappingKey”unwrapAlgorithm
Section titled “unwrapAlgorithm”string | SubtleCryptoEncryptAlgorithm
unwrappedKeyAlgorithm
Section titled “unwrappedKeyAlgorithm”string | SubtleCryptoImportKeyAlgorithm
extractable
Section titled “extractable”boolean
keyUsages
Section titled “keyUsages”string[]
Returns
Section titled “Returns”Promise<CryptoKey>
verify()
Section titled “verify()”verify(
algorithm,key,signature,data):Promise<boolean>
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1221
The verify() method of the SubtleCrypto interface verifies a digital signature.
Parameters
Section titled “Parameters”algorithm
Section titled “algorithm”string | SubtleCryptoSignAlgorithm
signature
Section titled “signature”ArrayBuffer | ArrayBufferView<ArrayBufferLike>
ArrayBuffer | ArrayBufferView<ArrayBufferLike>
Returns
Section titled “Returns”Promise<boolean>
wrapKey()
Section titled “wrapKey()”wrapKey(
format,key,wrappingKey,wrapAlgorithm):Promise<ArrayBuffer>
Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1291
The wrapKey() method of the SubtleCrypto interface ‘wraps’ a key.
Parameters
Section titled “Parameters”format
Section titled “format”string
wrappingKey
Section titled “wrappingKey”wrapAlgorithm
Section titled “wrapAlgorithm”string | SubtleCryptoEncryptAlgorithm
Returns
Section titled “Returns”Promise<ArrayBuffer>