Skip to content

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.

MDN Reference

new SubtleCrypto(): SubtleCrypto

SubtleCrypto

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.

MDN Reference

string | SubtleCryptoEncryptAlgorithm

CryptoKey

ArrayBuffer | ArrayBufferView<ArrayBufferLike>

Promise<ArrayBuffer>


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.

MDN Reference

string | SubtleCryptoDeriveKeyAlgorithm

CryptoKey

null | number

Promise<ArrayBuffer>


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.

MDN Reference

string | SubtleCryptoDeriveKeyAlgorithm

CryptoKey

string | SubtleCryptoImportKeyAlgorithm

boolean

string[]

Promise<CryptoKey>


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.

MDN Reference

string | SubtleCryptoHashAlgorithm

ArrayBuffer | ArrayBufferView<ArrayBufferLike>

Promise<ArrayBuffer>


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.

MDN Reference

string | SubtleCryptoEncryptAlgorithm

CryptoKey

ArrayBuffer | ArrayBufferView<ArrayBufferLike>

Promise<ArrayBuffer>


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.

MDN Reference

string

CryptoKey

Promise<ArrayBuffer | JsonWebKey>


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).

MDN Reference

string | SubtleCryptoGenerateKeyAlgorithm

boolean

string[]

Promise<CryptoKey | CryptoKeyPair>


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.

MDN Reference

string

ArrayBuffer | ArrayBufferView<ArrayBufferLike> | JsonWebKey

string | SubtleCryptoImportKeyAlgorithm

boolean

string[]

Promise<CryptoKey>


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.

MDN Reference

string | SubtleCryptoSignAlgorithm

CryptoKey

ArrayBuffer | ArrayBufferView<ArrayBufferLike>

Promise<ArrayBuffer>


timingSafeEqual(a, b): boolean

Defined in: node_modules/.pnpm/@cloudflare+workers-types@4.20251118.0/node_modules/@cloudflare/workers-types/index.ts:1311

ArrayBuffer | ArrayBufferView<ArrayBufferLike>

ArrayBuffer | ArrayBufferView<ArrayBufferLike>

boolean


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.

MDN Reference

string

ArrayBuffer | ArrayBufferView<ArrayBufferLike>

CryptoKey

string | SubtleCryptoEncryptAlgorithm

string | SubtleCryptoImportKeyAlgorithm

boolean

string[]

Promise<CryptoKey>


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.

MDN Reference

string | SubtleCryptoSignAlgorithm

CryptoKey

ArrayBuffer | ArrayBufferView<ArrayBufferLike>

ArrayBuffer | ArrayBufferView<ArrayBufferLike>

Promise<boolean>


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.

MDN Reference

string

CryptoKey

CryptoKey

string | SubtleCryptoEncryptAlgorithm

Promise<ArrayBuffer>