Skip to main content

WebCrypto Utilities

Standalone WebCrypto primitives for HMAC signing, AES-GCM encryption, and content hashing. Useful in workers and main thread; workers provide memory isolation for key material.

TypeScriptexample.ts
import { WebCrypto Utilities } from '@angular-helpers/worker-http/crypto'

# Methods

MethodSignatureReturnsDescription
createHmacSignercreateHmacSigner(config: HmacConfig): Promise<HmacSigner>Promise<HmacSigner>Creates an HMAC signer/verifier with the specified key material and algorithm.
signsign(data: string | ArrayBuffer): Promise<ArrayBuffer>Promise<ArrayBuffer>Creates an HMAC signature of the data.
verifyverify(data: string | ArrayBuffer, signature: ArrayBuffer): Promise<boolean>Promise<boolean>Verifies an HMAC signature against the data.
createAesEncryptorcreateAesEncryptor(config: AesConfig): Promise<AesEncryptor>Promise<AesEncryptor>Creates an AES-GCM encryptor/decryptor.
encryptencrypt(plaintext: string): Promise<EncryptedPayload>Promise<{ ciphertext: ArrayBuffer; iv: Uint8Array }>Encrypts plaintext using AES-GCM. Returns ciphertext and IV.
decryptdecrypt(payload: EncryptedPayload): Promise<ArrayBuffer>Promise<ArrayBuffer>Decrypts AES-GCM ciphertext using the provided IV.
createContentHashercreateContentHasher(algorithm?: HashAlgorithm): ContentHasherContentHasherCreates a content hasher for the specified algorithm.
hashhash(data: string | ArrayBuffer): Promise<ArrayBuffer>Promise<ArrayBuffer>Hashes the data using the configured algorithm.
LCP N/A
CLS N/A
INP N/A