From f304a1580b5ce7b6c5f9e25cd3ddc63ca8d8c6a1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 17 Dec 2021 13:58:07 +0100 Subject: Fix build --- shared/core-utils/common/crypto.ts | 20 -------------------- shared/core-utils/common/index.ts | 2 +- shared/core-utils/common/random.ts | 8 ++++++++ shared/extra-utils/crypto.ts | 20 ++++++++++++++++++++ shared/extra-utils/index.ts | 1 + 5 files changed, 30 insertions(+), 21 deletions(-) delete mode 100644 shared/core-utils/common/crypto.ts create mode 100644 shared/core-utils/common/random.ts create mode 100644 shared/extra-utils/crypto.ts (limited to 'shared') 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 @@ -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) -} - -// high excluded -function randomInt (low: number, high: number) { - return Math.floor(Math.random() * (high - low) + low) -} - -export { - randomInt, - sha256, - sha1 -} 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 @@ export * from './array' -export * from './crypto' +export * from './random' export * from './date' export * from './env' 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 @@ +// high excluded +function randomInt (low: number, high: number) { + return Math.floor(Math.random() * (high - low) + low) +} + +export { + randomInt +} 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 @@ +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) +} + +// high excluded +function randomInt (low: number, high: number) { + return Math.floor(Math.random() * (high - low) + low) +} + +export { + randomInt, + sha256, + sha1 +} 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 @@ +export * from './crypto' export * from './ffprobe' export * from './file' -- cgit v1.2.3