Generate Random Password In Ruby
Join the DZone community and get the full member experience.
Join For FreeAaron Blohowiak suggests adding this as a public method in user.rb:
def new_random_password
self.password= Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--")[0,6]
self.password_confirmation = self.password
end
Opinions expressed by DZone contributors are their own.
Comments