Skip to content

Instantly share code, notes, and snippets.

@qichunren
Created April 24, 2010 06:59
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 qichunren/377511 to your computer and use it in GitHub Desktop.
Save qichunren/377511 to your computer and use it in GitHub Desktop.
#产生随机的密码
def generate_password
chars = ("a".."z").to_a + ("0".."9").to_a
#puts chars
Array.new(6, '').collect{chars[rand(chars.size)]}.join
end
#测试
puts generate_password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment