Generates a hash digest of the provided data.
The parameters for the digest operation.
A Promise which will be fulfilled with the hash digest.
A digest is the output of the hash function. It's a fixed-size string of bytes that uniquely represents the data input into the hash function. The digest is often used for data integrity checks, as any alteration in the input data results in a significantly different digest.
It takes the algorithm identifier of the hash function and data to digest as input and returns the digest of the data.
const sha2 = new Sha2Algorithm();
const data = new TextEncoder().encode('Messsage');
const digest = await sha2.digest({ data });
The
Sha2Algorithm
class is an implementation of theHasher
interface for the SHA-2 family of cryptographic hash functions. Thedigest
method takes the algorithm identifier of the hash function and arbitrary data as input and returns the hash digest of the data.This class is typically accessed through implementations that extend the
CryptoApi
interface.