aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/core-utils/crypto.ts
blob: d6d1150d0a6052059964f5bee5d72308b944011b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { BinaryToTextEncoding, createHash } from 'crypto'

function sha256 (str: string | Buffer, encoding: BinaryToTextEncoding = 'hex') {
  return createHash('sha256').update(str).digest(encoding)
}

function sha1 (str: string | Buffer, encoding: BinaryToTextEncoding = 'hex') {
  return createHash('sha1').update(str).digest(encoding)
}

export {
  sha256,
  sha1
}