diff options
author | Chocobozzz <me@florianbigard.com> | 2021-12-17 13:58:07 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-12-17 13:58:07 +0100 |
commit | f304a1580b5ce7b6c5f9e25cd3ddc63ca8d8c6a1 (patch) | |
tree | 5d2b8e1c0e3ec05ad3e18cb59fe9ad84fac710eb /shared/core-utils | |
parent | c55e3d7227fe1453869e309025996b9d75256d5d (diff) | |
download | PeerTube-f304a1580b5ce7b6c5f9e25cd3ddc63ca8d8c6a1.tar.gz PeerTube-f304a1580b5ce7b6c5f9e25cd3ddc63ca8d8c6a1.tar.zst PeerTube-f304a1580b5ce7b6c5f9e25cd3ddc63ca8d8c6a1.zip |
Fix build
Diffstat (limited to 'shared/core-utils')
-rw-r--r-- | shared/core-utils/common/crypto.ts | 20 | ||||
-rw-r--r-- | shared/core-utils/common/index.ts | 2 | ||||
-rw-r--r-- | shared/core-utils/common/random.ts | 8 |
3 files changed, 9 insertions, 21 deletions
diff --git a/shared/core-utils/common/crypto.ts b/shared/core-utils/common/crypto.ts deleted file mode 100644 index 1a583f1a0..000000000 --- a/shared/core-utils/common/crypto.ts +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | import { BinaryToTextEncoding, createHash } from 'crypto' | ||
2 | |||
3 | function sha256 (str: string | Buffer, encoding: BinaryToTextEncoding = 'hex') { | ||
4 | return createHash('sha256').update(str).digest(encoding) | ||
5 | } | ||
6 | |||
7 | function sha1 (str: string | Buffer, encoding: BinaryToTextEncoding = 'hex') { | ||
8 | return createHash('sha1').update(str).digest(encoding) | ||
9 | } | ||
10 | |||
11 | // high excluded | ||
12 | function randomInt (low: number, high: number) { | ||
13 | return Math.floor(Math.random() * (high - low) + low) | ||
14 | } | ||
15 | |||
16 | export { | ||
17 | randomInt, | ||
18 | sha256, | ||
19 | sha1 | ||
20 | } | ||
diff --git a/shared/core-utils/common/index.ts b/shared/core-utils/common/index.ts index f9ba10d5e..720977ead 100644 --- a/shared/core-utils/common/index.ts +++ b/shared/core-utils/common/index.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | export * from './array' | 1 | export * from './array' |
2 | export * from './crypto' | 2 | export * from './random' |
3 | export * from './date' | 3 | export * from './date' |
4 | export * from './env' | 4 | export * from './env' |
5 | export * from './object' | 5 | export * from './object' |
diff --git a/shared/core-utils/common/random.ts b/shared/core-utils/common/random.ts new file mode 100644 index 000000000..705735d09 --- /dev/null +++ b/shared/core-utils/common/random.ts | |||
@@ -0,0 +1,8 @@ | |||
1 | // high excluded | ||
2 | function randomInt (low: number, high: number) { | ||
3 | return Math.floor(Math.random() * (high - low) + low) | ||
4 | } | ||
5 | |||
6 | export { | ||
7 | randomInt | ||
8 | } | ||