Updated components build.
This commit is contained in:
1 parent
5f27ba149b
commit
56af91950a
53 files changed
+942
-333
No files matched your search
@@ -1,5 +1,4 @@
|
||||
import crypto from 'crypto';
|
||||
import prand from 'pure-rand';
|
||||
import { v4, v5 } from 'uuid';
|
||||
|
||||
const ALGORITHM = 'aes-256-gcm';
|
||||
@@ -12,25 +11,6 @@ const ENC_POSITION = TAG_POSITION + TAG_LENGTH;
|
||||
const HASH_ALGO = 'sha512';
|
||||
const HASH_ENCODING = 'hex';
|
||||
|
||||
const seed = Date.now() ^ (Math.random() * 0x100000000);
|
||||
const rng = prand.xoroshiro128plus(seed);
|
||||
|
||||
export function random(min: number, max: number) {
|
||||
return prand.unsafeUniformIntDistribution(min, max, rng);
|
||||
}
|
||||
|
||||
export function getRandomChars(
|
||||
n: number,
|
||||
chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||
) {
|
||||
const arr = chars.split('');
|
||||
let s = '';
|
||||
for (let i = 0; i < n; i++) {
|
||||
s += arr[random(0, arr.length - 1)];
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
const getKey = (password: string, salt: Buffer) =>
|
||||
crypto.pbkdf2Sync(password, salt, 10000, 32, 'sha512');
|
||||
|
||||
|
||||
Reference in new issue
Block a user