Import source: backend/src/utils/crypto
Import the existing local project snapshot. This commit organizes existing files; it does not represent newly developed functionality.
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
import { createHash, randomBytes, randomUUID } from 'node:crypto';
|
||||||
|
|
||||||
|
export function randomId(bytes = 6) {
|
||||||
|
return randomBytes(bytes).toString('base64url');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function newUuid() {
|
||||||
|
return randomUUID();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function sha256(value: string) {
|
||||||
|
return createHash('sha256').update(value).digest('hex');
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user