Skip to content

Instantly share code, notes, and snippets.

@vladimir-e
Created March 5, 2013 16:36
Show Gist options
  • Save vladimir-e/5091630 to your computer and use it in GitHub Desktop.
Save vladimir-e/5091630 to your computer and use it in GitHub Desktop.
class App.Helper
generate_password: (length = 8) ->
charset = "abcdefghjknpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789_@=.%"
password = ""
i = 0
n = charset.length
while i < length
password += charset.charAt(Math.floor(Math.random() * n))
++i
password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment