randomizer.js 346 B

123456789101112131415
  1. // generate a random key (string)
  2. const generateKey = (prefix) => {
  3. let text = '';
  4. const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  5. for (let i = 0; i < 32; i += 1) {
  6. text += possible.charAt(Math.floor(Math.random() * possible.length));
  7. }
  8. return `${prefix}-${text}`;
  9. };
  10. export {
  11. generateKey
  12. };