Contact: aviboots(AT)netvision.net.il
31,111 questions
40,781 answers
573 users
function generate_random_string(size) { let characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; let randomChars = ""; for (let i = 0; i < size; i++) { randomChars += characters.charAt(Math.floor(Math.random() * characters.length)); } return randomChars; } console.log(generate_random_string(10)); console.log(generate_random_string(10)); /* run: ftYpjfMtrS tmOjeYAwac */
// base 36 - [0-9a-z] console.log((Math.random() + 1).toString(36).substring(2, 9)); console.log((Math.random() + 1).toString(36).substring(2, 5)); /* run: vzadiqx f0s */
console.log((Math.random() + 1).toString(36).substring(7)); console.log((Math.random() + 1).toString(36).substring(5)); console.log((Math.random() + 1).toString(36)); /* run: vunly 7zlo277 1.epxxxzsmno */
let crypto = require("crypto"); let rnd = crypto.randomBytes(30).toString('hex'); console.log(rnd); /* run: 228a9960f27687aff31332059a3fd2851906317e05334db1bd81e3d713d5 */