You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

12 lines
395 B

import { isoCrypto, isoUint8Array } from './iso/index.js';
/**
* Returns hash digest of the given data, using the given algorithm when provided. Defaults to using
* SHA-256.
*/
export function toHash(data, algorithm = -7) {
if (typeof data === 'string') {
data = isoUint8Array.fromUTF8String(data);
}
const digest = isoCrypto.digest(data, algorithm);
return digest;
}