aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-17 13:58:07 +0100
committerChocobozzz <me@florianbigard.com>2021-12-17 13:58:07 +0100
commitf304a1580b5ce7b6c5f9e25cd3ddc63ca8d8c6a1 (patch)
tree5d2b8e1c0e3ec05ad3e18cb59fe9ad84fac710eb /shared/extra-utils
parentc55e3d7227fe1453869e309025996b9d75256d5d (diff)
downloadPeerTube-f304a1580b5ce7b6c5f9e25cd3ddc63ca8d8c6a1.tar.gz
PeerTube-f304a1580b5ce7b6c5f9e25cd3ddc63ca8d8c6a1.tar.zst
PeerTube-f304a1580b5ce7b6c5f9e25cd3ddc63ca8d8c6a1.zip
Fix build
Diffstat (limited to 'shared/extra-utils')
-rw-r--r--shared/extra-utils/crypto.ts20
-rw-r--r--shared/extra-utils/index.ts1
2 files changed, 21 insertions, 0 deletions
diff --git a/shared/extra-utils/crypto.ts b/shared/extra-utils/crypto.ts
new file mode 100644
index 000000000..1a583f1a0
--- /dev/null
+++ b/shared/extra-utils/crypto.ts
@@ -0,0 +1,20 @@
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
11// high excluded
12function randomInt (low: number, high: number) {
13 return Math.floor(Math.random() * (high - low) + low)
14}
15
16export {
17 randomInt,
18 sha256,
19 sha1
20}
diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts
index 38303cf1f..373d27cb4 100644
--- a/shared/extra-utils/index.ts
+++ b/shared/extra-utils/index.ts
@@ -1,2 +1,3 @@
1export * from './crypto'
1export * from './ffprobe' 2export * from './ffprobe'
2export * from './file' 3export * from './file'