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
| Method | Signature | Returns | Description |
|---|---|---|---|
createHmacSigner | createHmacSigner(config: HmacConfig): Promise<HmacSigner> | Promise<HmacSigner> | Creates an HMAC signer/verifier with the specified key material and algorithm. |
sign | sign(data: string | ArrayBuffer): Promise<ArrayBuffer> | Promise<ArrayBuffer> | Creates an HMAC signature of the data. |
verify | verify(data: string | ArrayBuffer, signature: ArrayBuffer): Promise<boolean> | Promise<boolean> | Verifies an HMAC signature against the data. |
createAesEncryptor | createAesEncryptor(config: AesConfig): Promise<AesEncryptor> | Promise<AesEncryptor> | Creates an AES-GCM encryptor/decryptor. |
encrypt | encrypt(plaintext: string): Promise<EncryptedPayload> | Promise<{ ciphertext: ArrayBuffer; iv: Uint8Array }> | Encrypts plaintext using AES-GCM. Returns ciphertext and IV. |
decrypt | decrypt(payload: EncryptedPayload): Promise<ArrayBuffer> | Promise<ArrayBuffer> | Decrypts AES-GCM ciphertext using the provided IV. |
createContentHasher | createContentHasher(algorithm?: HashAlgorithm): ContentHasher | ContentHasher | Creates a content hasher for the specified algorithm. |
hash | hash(data: string | ArrayBuffer): Promise<ArrayBuffer> | Promise<ArrayBuffer> | Hashes the data using the configured algorithm. |