/ Published in: Ruby
Generate random password.
e.g. reset user's password.
e.g. reset user's password.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
def generate_password(length=6) chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ23456789' password = '' length.downto(1) { |i| password << chars[rand(chars.length - 1)] } password end