From f304a1580b5ce7b6c5f9e25cd3ddc63ca8d8c6a1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 17 Dec 2021 13:58:07 +0100 Subject: Fix build --- shared/extra-utils/crypto.ts | 20 ++++++++++++++++++++ shared/extra-utils/index.ts | 1 + 2 files changed, 21 insertions(+) create mode 100644 shared/extra-utils/crypto.ts (limited to 'shared/extra-utils') 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