Yum….

def password=(pw)
@password = pw
salt = [Array.new(6){rand(256).chr}.join].pack("m").chomp
self.password_salt, self.password_hash = salt, Digest::MD5.hexdigest(pw + salt)
end

Note that the line [Array.new(6){rand(250).chr}.join].pack("m").chomp is a good way to auto-generate passwords. ;) Have a bit of fun with it.

~ by deadbadger on April 24, 2008.

Leave a Reply