Skip to content

Instantly share code, notes, and snippets.

@HungYuHei
Created November 4, 2011 06:14
Show Gist options
  • Select an option

  • Save HungYuHei/1338772 to your computer and use it in GitHub Desktop.

Select an option

Save HungYuHei/1338772 to your computer and use it in GitHub Desktop.
生成随机密码
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