Bun

class

SubtleCrypto

class SubtleCrypto

This Web Crypto API interface provides a number of low-level cryptographic functions. It is accessed via the Crypto.subtle properties available in a window context (via Window.crypto). Available only in secure contexts.

MDN Reference

  • algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
    key: CryptoKey,
    data: BufferSource
    ): Promise<ArrayBuffer>;
  • algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params,
    baseKey: CryptoKey,
    length?: null | number
    ): Promise<ArrayBuffer>;
  • algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params,
    baseKey: CryptoKey,
    derivedKeyType: AlgorithmIdentifier | HkdfParams | Pbkdf2Params | AesDerivedKeyParams | HmacImportParams,
    extractable: boolean,
    keyUsages: KeyUsage[]
    ): Promise<CryptoKey>;
    algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params,
    baseKey: CryptoKey,
    derivedKeyType: AlgorithmIdentifier | HkdfParams | Pbkdf2Params | AesDerivedKeyParams | HmacImportParams,
    extractable: boolean,
    keyUsages: Iterable<KeyUsage>
    ): Promise<CryptoKey>;
  • algorithm: AlgorithmIdentifier,
    data: BufferSource
    ): Promise<ArrayBuffer>;
  • algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
    key: CryptoKey,
    data: BufferSource
    ): Promise<ArrayBuffer>;
  • format: 'jwk',
    ): Promise<JsonWebKey>;
    format: 'spki' | 'pkcs8' | 'raw',
    ): Promise<ArrayBuffer>;
    format: KeyFormat,
    ): Promise<ArrayBuffer | JsonWebKey>;
  • algorithm: 'Ed25519' | { name: 'Ed25519' },
    extractable: boolean,
    keyUsages: readonly 'sign' | 'verify'[]
    ): Promise<CryptoKeyPair>;
    algorithm: RsaHashedKeyGenParams | EcKeyGenParams,
    extractable: boolean,
    keyUsages: readonly KeyUsage[]
    ): Promise<CryptoKeyPair>;
    algorithm: Pbkdf2Params | AesKeyGenParams | HmacKeyGenParams,
    extractable: boolean,
    keyUsages: readonly KeyUsage[]
    ): Promise<CryptoKey>;
    algorithm: AlgorithmIdentifier,
    extractable: boolean,
    keyUsages: KeyUsage[]
    ): Promise<CryptoKey | CryptoKeyPair>;
    algorithm: AlgorithmIdentifier,
    extractable: boolean,
    keyUsages: Iterable<KeyUsage>
    ): Promise<CryptoKey | CryptoKeyPair>;
  • format: 'jwk',
    keyData: JsonWebKey,
    algorithm: AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm,
    extractable: boolean,
    keyUsages: readonly KeyUsage[]
    ): Promise<CryptoKey>;
    format: 'spki' | 'pkcs8' | 'raw',
    keyData: BufferSource,
    algorithm: AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm,
    extractable: boolean,
    keyUsages: KeyUsage[]
    ): Promise<CryptoKey>;
    format: 'spki' | 'pkcs8' | 'raw',
    keyData: BufferSource,
    algorithm: AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm,
    extractable: boolean,
    keyUsages: Iterable<KeyUsage>
    ): Promise<CryptoKey>;
  • algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams,
    key: CryptoKey,
    data: BufferSource
    ): Promise<ArrayBuffer>;
  • format: KeyFormat,
    wrappedKey: BufferSource,
    unwrappingKey: CryptoKey,
    unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
    unwrappedKeyAlgorithm: AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm,
    extractable: boolean,
    keyUsages: KeyUsage[]
    ): Promise<CryptoKey>;
    format: KeyFormat,
    wrappedKey: BufferSource,
    unwrappingKey: CryptoKey,
    unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams,
    unwrappedKeyAlgorithm: AlgorithmIdentifier | HmacImportParams | RsaHashedImportParams | EcKeyImportParams | AesKeyAlgorithm,
    extractable: boolean,
    keyUsages: Iterable<KeyUsage>
    ): Promise<CryptoKey>;
  • algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams,
    key: CryptoKey,
    signature: BufferSource,
    data: BufferSource
    ): Promise<boolean>;
  • format: KeyFormat,
    key: CryptoKey,
    wrappingKey: CryptoKey,
    wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams
    ): Promise<ArrayBuffer>;