12 lines
420 B
JavaScript
12 lines
420 B
JavaScript
/*
|
|
! /services/idGenerator.js
|
|
= Central Unique ID-Generator
|
|
? This module will create unique ids using crypto
|
|
*/
|
|
|
|
// % import nodejs dependencies
|
|
import crypto from 'crypto';
|
|
|
|
// $ create a new unique id
|
|
export function generate() { return crypto.randomBytes(32).toString('hex'); } // simple id generator
|
|
export function generatePrefixed(prefix) { return `${prefix}_${generate()}`; } // prefixed id generator
|