const accents = 'áéíóú', chars = 'abcdefghijklmnopqrstuvwxyz', a = 'bcdfghijklmnpqrstuvwxyzñ', b = 'aeilorsuy', c = 'aeioruhtlkkkkkkkkk', d = 'aeiourldns', e = 'abcdefyrnsltmpxizñ', f = 'aeiouylrf', g = 'aeiouhrlmns', h = 'aeiourlt', i = 'encstoadlmvzrgfrtpbkñ', j = 'uaoei', k = 'eiaolunyhsrw', l = 'eiayoug', m = 'aeiouypb', n = 'aeiouytgdcsn', o = 'abcdefnruplsmtzñ', p = 'rehaoilhtusp', q = 'u', r = 'aeioutymscdrnpb', s = 'etshaicupomlynk', t = 'eiraohuytlar', u = 'bcdfghnslrmtiaepzñ', v = 'eiaour', w = 'aeiouyhrnls', x = 'aeiouytcpl', y = 'elstacpnm', z = 'eaioyuz', ñ = 'aeiou'; const rando = () => { try { let crypto try { crypto = require('crypto').randomFillSync } catch (_) { crypto = (window.crypto || window.msCrypto).getRandomValues } let cryptoRandoms const cryptoRandomSlices = [] let cryptoRandom while ((cryptoRandom = '.' + cryptoRandomSlices.join('')).length < 30) { cryptoRandoms = crypto(new Uint32Array(5)) for (let i = 0; i < cryptoRandoms.length; i++) { const cryptoRandomSlice = cryptoRandoms[i] < 4000000000 ? cryptoRandoms[i].toString().slice(1) : '' if (cryptoRandomSlice.length > 0) cryptoRandomSlices[cryptoRandomSlices.length] = cryptoRandomSlice } } return Number(cryptoRandom) } catch (_) { return Math.random() } } function rng (doAccents = true, min = 4, max = 8, length = Math.floor(rando() * (max - min + 1)) + min, firstChar = chars[Math.floor(rando() * chars.length)]) { let out = []; for (let index = 0; index < length; index++) { if (index == 0) { out.push(firstChar); } else { out.push(eval(out[index-1])[Math.floor(rando() * eval(out[index-1]).length)]); } } if (doAccents) { out = addAccents(out); } if (out[out.length-1] == "ñ") { out.push(ñ[Math.floor(rando() * ñ.length)]); } return [out[0].toUpperCase(), ...out.slice(1)].join(''); } function addAccents(arr) { let hasAccent = false; let outVowels = arr.filter(a => ñ.includes(a)); let lastVowel = outVowels[outVowels.length-1]; for (let i = 0; i < arr.length; i++) { let char = arr[i]; let newChar; if (rando() >= 0.5 && !hasAccent && ñ.includes(char)) { newChar = accents[ñ.indexOf(char)]; hasAccent = true; } else if (lastVowel == char && !hasAccent) { newChar = accents[ñ.indexOf(char)]; hasAccent = true; } arr[i] = newChar || char; } return arr; } for(let i = 0; i < 10; i++) { console.log(rng(true, 5, 6)); console.log(""); console.log(rng(false, 4, 8)); console.log(""); } // good names: garnguck, lemock, wemee, yermpoo, jelifyeshi, vazaji, zufazi, dupunt, trythluid /* more good names: elóra, yáddro, lezíe, janeño, bahúz, gouñuña, volgrad, flizz, tunck, vorag, sylem, kitala, vunos, jaith, qumor, henup, ornda, zilep, cantadu, gromu, lodley */
- const accents = 'áéíóú',
- chars = 'abcdefghijklmnopqrstuvwxyz',
- a = 'bcdfghijklmnpqrstuvwxyzñ',
- b = 'aeilorsuy',
- c = 'aeioruhtlkkkkkkkkk',
- d = 'aeiourldns',
- e = 'abcdefyrnsltmpxizñ',
- f = 'aeiouylrf',
- g = 'aeiouhrlmns',
- h = 'aeiourlt',
- i = 'encstoadlmvzrgfrtpbkñ',
- j = 'uaoei',
- k = 'eiaolunyhsrw',
- l = 'eiayoug',
- m = 'aeiouypb',
- n = 'aeiouytgdcsn',
- o = 'abcdefnruplsmtzñ',
- p = 'rehaoilhtusp',
- q = 'u',
- r = 'aeioutymscdrnpb',
- s = 'etshaicupomlynk',
- t = 'eiraohuytlar',
- u = 'bcdfghnslrmtiaepzñ',
- v = 'eiaour',
- w = 'aeiouyhrnls',
- x = 'aeiouytcpl',
- y = 'elstacpnm',
- z = 'eaioyuz',
- ñ = 'aeiou';
function rng (doAccents = true, min = 4, max = 8, length = Math.floor(Math.random() * (max - min + 1)) + min, firstChar = chars[Math.floor(Math.random() * chars.length)]) {- const rando = () => {
- try {
- let crypto
- try {
- crypto = require('crypto').randomFillSync
- } catch (_) {
- crypto = (window.crypto || window.msCrypto).getRandomValues
- }
- let cryptoRandoms
- const cryptoRandomSlices = []
- let cryptoRandom
- while ((cryptoRandom = '.' + cryptoRandomSlices.join('')).length < 30) {
- cryptoRandoms = crypto(new Uint32Array(5))
- for (let i = 0; i < cryptoRandoms.length; i++) {
- const cryptoRandomSlice = cryptoRandoms[i] < 4000000000 ? cryptoRandoms[i].toString().slice(1) : ''
- if (cryptoRandomSlice.length > 0) cryptoRandomSlices[cryptoRandomSlices.length] = cryptoRandomSlice
- }
- }
- return Number(cryptoRandom)
- } catch (_) {
- return Math.random()
- }
- }
- function rng (doAccents = true, min = 4, max = 8, length = Math.floor(rando() * (max - min + 1)) + min, firstChar = chars[Math.floor(rando() * chars.length)]) {
- let out = [];
- for (let index = 0; index < length; index++) {
- if (index == 0) {
- out.push(firstChar);
- } else {
out.push(eval(out[index-1])[Math.floor(Math.random() * eval(out[index-1]).length)]);- out.push(eval(out[index-1])[Math.floor(rando() * eval(out[index-1]).length)]);
- }
- }
- if (doAccents) {
- out = addAccents(out);
- }
- if (out[out.length-1] == "ñ") {
out.push(ñ[Math.floor(Math.random() * ñ.length)]);- out.push(ñ[Math.floor(rando() * ñ.length)]);
- }
return out.join('');- return [out[0].toUpperCase(), ...out.slice(1)].join('');
- }
- function addAccents(arr) {
- let hasAccent = false;
- let outVowels = arr.filter(a => ñ.includes(a));
- let lastVowel = outVowels[outVowels.length-1];
- for (let i = 0; i < arr.length; i++) {
- let char = arr[i];
- let newChar;
if (Math.random() >= 0.5 && !hasAccent && ñ.includes(char)) {- if (rando() >= 0.5 && !hasAccent && ñ.includes(char)) {
- newChar = accents[ñ.indexOf(char)];
- hasAccent = true;
- } else if (lastVowel == char && !hasAccent) {
- newChar = accents[ñ.indexOf(char)];
- hasAccent = true;
- }
- arr[i] = newChar || char;
- }
- return arr;
- }
- for(let i = 0; i < 10; i++) {
- console.log(rng(true, 5, 6));
- console.log("");
- console.log(rng(false, 4, 8));
- console.log("");
- }
- // good names: garnguck, lemock, wemee, yermpoo, jelifyeshi, vazaji, zufazi, dupunt, trythluid
- /* more good names:
- elóra, yáddro, lezíe, janeño, bahúz, gouñuña,
- volgrad, flizz, tunck, vorag, sylem, kitala, vunos, jaith, qumor, henup, ornda, zilep, cantadu, gromu, lodley
- */