Initial commit
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
const crypto = require('crypto');
|
||||
|
||||
const ALPHABET = 'ABCDEFGHJKLMNPQRSTUVWXYZ23456789'; // no O/0/I/1 to avoid ambiguity
|
||||
|
||||
function generateInviteCode(length = 6) {
|
||||
let code = '';
|
||||
for (let i = 0; i < length; i++) {
|
||||
code += ALPHABET[crypto.randomInt(0, ALPHABET.length)];
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
module.exports = { generateInviteCode };
|
||||
Reference in New Issue
Block a user