1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-23 22:36:32 +02:00

Chore: Add function to generate secure random values (#9409)

Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
This commit is contained in:
pedr
2023-12-14 12:28:41 -03:00
committed by GitHub
parent e761b97944
commit d63b84ee1f
4 changed files with 22 additions and 31 deletions

View File

@@ -1,5 +1,6 @@
import { v4 as uuidv4 } from 'uuid';
import { customAlphabet } from 'nanoid/non-secure';
import { nanoid as nanoidSecure } from 'nanoid';
// https://zelark.github.io/nano-id-cc/
// https://security.stackexchange.com/a/41749/1873
@@ -21,6 +22,10 @@ export default {
},
};
export const createSecureRandom = (size = 32) => {
return nanoidSecure(size);
};
type FuncUiidGen = (length?: number)=> string;
const cachedUuidgen: Record<number, FuncUiidGen> = {};