SHA-256 cryptographic hash function implementation for TypeScript and JavaScript
91
A utility for computing SHA-256 hashes with custom buffer management to minimize memory allocations in performance-critical applications.
Implement a hash buffer manager that:
The manager should allow users to compute hashes efficiently by reusing buffers from the pool. When a buffer is no longer needed, it should be returned to the pool for reuse.
@generates
/**
* Manages a pool of pre-allocated buffers for SHA-256 hash outputs
*/
export class HashBufferManager {
/**
* Creates a new hash buffer manager with a specified pool size
* @param poolSize - Number of buffers to pre-allocate in the pool
*/
constructor(poolSize: number);
/**
* Computes a SHA-256 hash and writes it to a buffer from the pool
* @param data - Input data to hash
* @returns An object containing the hash buffer and a release function
* @throws Error if no buffers are available in the pool
*/
computeHash(data: Uint8Array): { buffer: Uint8Array; release: () => void };
/**
* Returns statistics about buffer pool usage
* @returns Object with total and available buffer counts
*/
getPoolStats(): { total: number; available: number };
}Provides SHA-256 cryptographic hash functionality.
Install with Tessl CLI
npx tessl i tessl/npm-stablelib--sha256docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10