Skip to content

Instantly share code, notes, and snippets.

@lusentis
Created June 30, 2012 19:24
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 lusentis/3025174 to your computer and use it in GitHub Desktop.
Save lusentis/3025174 to your computer and use it in GitHub Desktop.
Browser-JS random password generator applet
//- 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