summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/helpers/toHash.ts
blob: 007b1ab75c2692d9a5650f5d9ce7b62caf444b84 (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 function toHash(data: Buffer | string, algo = 'SHA256'): Buffer {
  return crypto.createHash(algo).update(data).digest();
}