Created
May 11, 2013 11:54
-
-
Save tuki0918/5559769 to your computer and use it in GitHub Desktop.
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
Password = | |
SYMBOL: '!"#$%&\'()' | |
NUMBER: '1234567890' | |
ABC_L: 'abcdefghijklmnopqrstuvwxyz' | |
ABC_U: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' | |
generate: (len)-> | |
password = '' | |
# 11以下 -> 12, 17以上 -> 16 | |
len = 12 if typeof len is 'undefined' or len <= 11 | |
len = 16 if len >= 17 | |
key = (Password.NUMBER + Password.SYMBOL + Password.ABC_L + Password.ABC_U).split('') | |
keyLen = key.length | |
for i in [1..len] | |
password += key[Math.floor(Math.random() * keyLen)] | |
return password | |
# パスワードの作成 | |
for i in [10..18] | |
console.log "#{i}: #{Password.generate(i).length}" #{Password.generate(i)}" | |
# console.log Password.generate(14) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment