Last active
November 12, 2021 22:28
-
-
Save boscomonkey/33f71154d4caa1c1f46ac7b8066add2d to your computer and use it in GitHub Desktop.
Bookmarklet to take XKCD password - https://preshing.com/20110811/xkcd-password-generator/ - and turn it into caps, special chars (periods), and numbers.
This file contains hidden or 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() { | |
function massage_xkcd(txt) { | |
const arry = txt.split(' '); | |
const randNum = String(Math.random()).slice(2, 5); | |
const caps = arry.map(word => word.charAt(0).toUpperCase() + word.substring(1)); | |
caps.push(randNum); | |
return caps.join('.'); | |
} | |
const elt = document.getElementById('xkcd_pw_gen_result'); | |
const txt = elt.innerText; | |
const passwd = massage_xkcd(txt); | |
alert(passwd); | |
} | |
)() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Revision 2 uses a much clearer way of generating 3 digits (with leading zeros if necessary):
instead of the old opaque way: