When the password get's assigned, it is automatically "MySQL encrypted". Here's ther code for reference:
def password=(pw)
self[:password] = mysql_encrypt(pw)
end
private
def mysql_encrypt(pw)
salt = [Array.new(6){rand(256).chr}.join].pack("m").chomp
return pw.crypt(salt)
end
2 comments:
so has this way been successful for you? I just came across a db column that uses mysql's encrypt function, and wanted to know if this was the best way to do it? cheers. good work.
Thanks for sharing this. I hereby tag this blog post as #useful! :-)
Post a Comment