2024-08-22 07:34:39 -04:00
|
|
|
const crypto = require('crypto')
|
2024-07-28 02:37:31 -04:00
|
|
|
const rsg = function (count) {
|
|
|
|
let output = ''
|
|
|
|
for (let i = 0; i < count; i++) {
|
2024-08-12 05:13:32 -04:00
|
|
|
const type = Math.floor(Math.random() * 6)
|
|
|
|
switch (type) {
|
|
|
|
case 0:
|
|
|
|
output += ' '
|
|
|
|
break
|
|
|
|
case 1:
|
|
|
|
output += '§§'
|
|
|
|
break
|
|
|
|
case 2:
|
|
|
|
output += '§ '
|
|
|
|
break
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
case 5:{ // Make this case more likely
|
|
|
|
let rng = Math.floor(Math.random() * 16) + 1
|
|
|
|
if (rng === 7) rng = 17 // No bells
|
|
|
|
if (rng === 10) rng = 18 // No line feeds
|
|
|
|
if (rng === 11) rng = 19 // No vertical tabulations
|
|
|
|
if (rng === 12) rng = 20 // No form feed
|
|
|
|
if (rng === 13) rng = 21 // No carriage returns
|
|
|
|
if (rng === 14) rng = 22 // No shift out
|
|
|
|
if (rng === 15) rng = 23 // No shift in
|
|
|
|
output += `§${String.fromCharCode(rng)}`
|
|
|
|
}
|
|
|
|
}
|
2024-07-27 02:39:18 -04:00
|
|
|
}
|
2024-07-28 02:37:31 -04:00
|
|
|
return output
|
2024-07-27 02:39:18 -04:00
|
|
|
}
|
2024-08-22 07:34:39 -04:00
|
|
|
const rsgLegal = function (count) {
|
|
|
|
let output = ''
|
2024-08-25 22:26:03 -04:00
|
|
|
if (Math.random() > 0.5) {
|
|
|
|
output += 'uwu_'
|
2024-08-22 07:34:39 -04:00
|
|
|
} else {
|
2024-08-25 22:26:03 -04:00
|
|
|
output += 'owo_'
|
2024-08-22 07:34:39 -04:00
|
|
|
}
|
2024-08-25 22:26:03 -04:00
|
|
|
output += crypto.randomBytes(count).toString('hex')
|
2024-08-22 07:34:39 -04:00
|
|
|
return output
|
|
|
|
}
|
2024-07-27 02:39:18 -04:00
|
|
|
module.exports = function (legal) {
|
2024-07-28 02:37:31 -04:00
|
|
|
if (legal) {
|
2024-08-22 07:34:39 -04:00
|
|
|
return rsgLegal(6)
|
2024-07-27 02:39:18 -04:00
|
|
|
} else {
|
2024-08-12 05:13:32 -04:00
|
|
|
return rsg(6 + Math.floor(Math.random() * 3))
|
2024-07-27 02:39:18 -04:00
|
|
|
}
|
|
|
|
}
|