Crypto module · API reference
Hash data without coupling the pipeline to one runtime.
The Hash base class gives synchronous, asynchronous, and batched hashing implementations one shape. Choose the algorithm separately from the code that feeds it bytes.
Choose the operation
Keep hashing at the same boundary as the bytes.
Use hash() for a complete buffer, hashSync() when the implementation is already loaded, and hashBatches() when data arrives through a streaming pipeline.
Algorithm
Select a concrete Hash implementation
Async
Hash one ArrayBuffer without blocking the caller
Sync
Use a preloaded implementation for local work
Batches
Hash an AsyncIterable of binary chunks
Detailed guide
Hash API details
The reference below documents support detection, preload requirements, output encodings, and the fallback behavior for non-streaming algorithms.
Hash
Hash is the abstract base class for loaders.gl hash classes.
Fields
name: string
The name of the hash algorithm
isSupported: boolean
Methods
preload()
preload(): Promise<void>
Asynchronously loads required libraries. For some hash classes this must be completed before
hashSync() is available.
hash()
hash.hash(data: ArrayBuffer, encoding: 'hex' | 'base64'): Promise<ArrayBuffer>
Asynchronously hashes data.
hashSync()
hash.hashSync(data: ArrayBuffer, encoding: 'hex' | 'base64'): ArrayBuffer
Synchronously hashes data.
For some hash sub classes, preload() must have been called and completed before
synchronous operations are available.
hashInBactches()
hash.hashBatches(data: AsyncIterable<ArrayBuffer>, encoding: 'hex' | 'base64'): AsyncIterable<ArrayBuffer>
Asynchronously hashes data in batches.
If the underlying hashion does not support streaming hashion,
the incoming data will be concatenated into a single ArrayBuffer
and a single hashed batch will be yielded.