Created
June 30, 2012 19:24
-
-
Save lusentis/3025174 to your computer and use it in GitHub Desktop.
Browser-JS random password generator applet
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
//- A general purpose not-so-random string generator | |
//- This file is in public domain | |
//- by Simone Lusenti - PlasticPanda.com, 2012 | |
doctype 5 | |
html | |
head | |
meta(charset='utf-8') | |
meta(name='Content-Type', value='text/html') | |
title Random pass generator | |
:stylus | |
.mini | |
font-size small | |
body | |
header | |
p Some random passwords for you: | |
section#content | |
footer | |
p | |
button#again Again! | |
br | |
span.mini | |
a(href="https://gist.github.com/gists/3025174") view source | |
:coffeescript | |
options = window.location.hash.replace('#','').split ',' | |
howMany = parseInt(options[0]) || 10 | |
length = parseInt(options[1]) || 10 | |
# Random password generator | |
randPass = () -> | |
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' | |
pass = [pass] + chars.charAt Math.floor Math.random()*(chars.length-1) for c in [1..length] | |
return pass | |
generate = () -> | |
for c in [1..howMany] | |
document.getElementById('content').innerHTML += "#{randPass()}<br />" | |
document.getElementById('again').onclick = (ev) -> | |
document.getElementById('content').innerHTML = '' | |
generate() | |
generate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment