// /utils/credentials.js 'use strict'; const crypto = require('crypto'); const LETTERS = 'abcdefghijkmnpqrstuvwxyz'; const DIGITS = '23456789'; const randomFrom = (alphabet, length) => { let out = ''; const bytes = crypto.randomBytes(length); for (let i = 0; i < length; i += 1) { out += alphabet[bytes[i] % alphabet.length]; } return out; }; /** Simple password: exactly 2 English letters + 4 digits (e.g. kx4821) */ const generateSimplePassword = () => `${randomFrom(LETTERS, 2)}${randomFrom(DIGITS, 4)}`; /** Random username: u + 6 digits (e.g. u482910) */ const generateUsername = () => `u${randomFrom(DIGITS, 6)}`; module.exports = { generateSimplePassword, generateUsername, };