Last active
May 1, 2019 15:28
-
-
Save donpdonp/ba1b6d9c4a6a06897be638f572995de6 to your computer and use it in GitHub Desktop.
gluon password generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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