Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"The password should not contain a sequence or repeated characters. For example, aaa123 is an invalid password."
// also no control characters or spaces...
var crypto = require('crypto');
var b32 = require('thirty-two');
function randomStr(n) {
var randb32 = b32.encode(crypto.randomBytes(n)).toString('utf8');
var idx = randb32.indexOf('=');
return randb32.substr(0, idx > 0 ? idx : randb32.length);
}
function interpose(str, y) {
var ret = [];
for (var i = 0; i < str.length; i++) {
ret.push(str[i]);
}
return ret.join(y);
}
for (var i = 0; i < 6; i++) {
console.log(interpose(randomStr(16), 'a'));
}
// => ZaRaYaXa5aSaBaBaNaNaGaRa5a6aTa6aYaCaHaWa4a4aOaKaHaE
// => WaMaSaGaRa4a3aFaLa5aPaZaYaKaCaBaHaSaQaLaOaOaFaLa6aA
// => OaGa6aVaWaKa2aMaKaUaKaUaVaVaRaWaGaVa7aRaJaXa4aSaOaQ
// => VaGa7aDa5aQaXaIaAaDa7aNaQa6aHa3a2a6aJaEaCaWaGaKaTaI
// => DaHa7a4aTaMaYaIaQaJa3aKaMaBaYaNaXaAaAa7aPaGaNaBaVaE
// => HaUaWa2aTa6aBaWaTaJaHaCa4aNaCaLaAaDaWa7aRaHaNa6aLaU
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.