Skip to content

Instantly share code, notes, and snippets.

@donpdonp
Last active May 1, 2019 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donpdonp/ba1b6d9c4a6a06897be638f572995de6 to your computer and use it in GitHub Desktop.
Save donpdonp/ba1b6d9c4a6a06897be638f572995de6 to your computer and use it in GitHub Desktop.
gluon password generator
(function() {
// descriptor
return {name: "pwgen"}
})
var charset="abcdefghijklmnopqrstuvwxyz"+
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"+
"1234567890!@#$%^&*()_+-=[]{};':\",./<>?`~";
function go(msg) {
if (msg.method == "irc.privmsg") {
var cmd_match = /^!pwgen(\s+(\S+))?/.exec(msg.params.message)
if(cmd_match) {
var len = parseInt(cmd_match[2]) || 16
bot.say(msg.params.channel, makepass(len))
}
}
}
function makepass(pwlen) {
var pw = ""
for (var i=0; i<pwlen; i++) {
var random_index = parseInt(Math.random()*(charset.length))
pw = pw + charset[random_index]
}
return pw
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment