You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-29 22:48:10 +02:00
This commit is contained in:
9
packages/utils/crypto.ts
Normal file
9
packages/utils/crypto.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
|
||||
import { randomBytes } from 'crypto';
|
||||
|
||||
export const getSecureRandomString = (length: number): string => {
|
||||
const bytes = randomBytes(Math.ceil(length * 2));
|
||||
const randomString = bytes.toString('base64').replace(/[^a-zA-Z0-9]/g, '');
|
||||
return randomString.slice(0, length);
|
||||
};
|
||||
Reference in New Issue
Block a user