SHA-256 cryptographic hash function implementation for TypeScript and JavaScript
91
Build a utility that validates hash digests and properly sizes buffers for hash operations.
Implement a module that provides functions to:
The module should handle validation and buffer management correctly for cryptographic hash operations.
@generates
/**
* Checks if a buffer is the correct size for a hash digest
* @param buffer - The buffer to validate
* @returns true if buffer is correct size, false otherwise
*/
export function isValidDigestSize(buffer: Uint8Array): boolean;
/**
* Allocates a new buffer with the correct size for a hash digest
* @returns A new Uint8Array with the correct size
*/
export function allocateDigestBuffer(): Uint8Array;
/**
* Checks if data length is aligned to the block size boundary
* @param dataLength - Length of data in bytes
* @returns true if data is block-aligned, false otherwise
*/
export function isBlockAligned(dataLength: number): boolean;
/**
* Calculates how many complete blocks can be processed from the data
* @param dataLength - Length of data in bytes
* @returns Number of complete blocks
*/
export function calculateCompleteBlocks(dataLength: number): number;Provides cryptographic hashing with standard algorithm constants.
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