@tiny-utils/crypto
Version:
Tiny utils for crypto: asymmetric/symmetric encryption, ed25519, sha256, etc.
12 lines (10 loc) • 379 B
text/typescript
import jssha256 from 'js-sha256';
/**
* @category Crypto
* @description Method to calculate SHA256 hash of the arbitrary data (bytes array or string)
* @param data Data to calculate hash
* @returns 32-bytes array with the SHA256 hash of the data
*/
export const sha256 = (data: string | Uint8Array): Uint8Array => {
return new Uint8Array(jssha256.sha256.digest(data));
};