]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/extra-utils/crypto.ts
Add ability to list imports of a channel sync
[github/Chocobozzz/PeerTube.git] / shared / extra-utils / crypto.ts
CommitLineData
06aad801 1import { BinaryToTextEncoding, createHash } from 'crypto'
2
3function sha256 (str: string | Buffer, encoding: BinaryToTextEncoding = 'hex') {
4 return createHash('sha256').update(str).digest(encoding)
5}
6
7function sha1 (str: string | Buffer, encoding: BinaryToTextEncoding = 'hex') {
8 return createHash('sha1').update(str).digest(encoding)
9}
10
c55e3d72
C
11// high excluded
12function randomInt (low: number, high: number) {
13 return Math.floor(Math.random() * (high - low) + low)
14}
15
06aad801 16export {
c55e3d72 17 randomInt,
06aad801 18 sha256,
19 sha1
20}