Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
How can I encrypt a string with MD5 in Rails 3.0 ? pass = MD5.hexdigest(pass) in a model yields uninitialized constant MyModel::MD5
pass = MD5.hexdigest(pass)
uninitialized constant MyModel::MD5
您可以Digest::MD5从 Ruby 标准库中使用它。
Digest::MD5
irb(main):001:0> require 'digest/md5' => true irb(main):002:0> Digest::MD5.hexdigest('foobar') => "3858f62230ac3c915f300c664312c63f"
还有一件事:MD5 是一种哈希算法。您不会使用散列算法“加密”任何内容。