Files
LupiNex-Connect/services/idgen.js
T
2026-06-29 20:14:06 +02:00

14 lines
470 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
! /services/idgen.js Central Unique ID-Generator
? This module will create unique ids using crypto
*/
// % import nodejs dependencies
const crypto = require('crypto');
// $ create a new unique id
const generate = () => crypto.randomBytes(32).toString('hex'); // simple id generator
const generatePrefixed = (prefix) => `${prefix}_${generate()}`; // prefixed id generator
// § export id-generator module
module.exports = { generate, generatePrefixed };