Created
November 4, 2011 06:14
-
-
Save HungYuHei/1338772 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
| def generate_password(length=6) | |
| chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ23456789' | |
| password = '' | |
| length.times { |i| password << chars[rand(chars.length)] } | |
| password | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment