blob: 68ed0898f78b73ab51fdfbe06bc3174629d5560d (
plain)
1
2
3
4
5
6
7
8
9
10
|
import crypto from 'crypto';
/**
* Returns hash digest of the given data using the given algorithm.
* @param data Data to hash
* @return The hash
*/
export default function toHash(data: Buffer | string, algo = 'SHA256'): Buffer {
return crypto.createHash(algo).update(data).digest();
}
|