Digest::MD5 in Ruby 1.9.3 Digest::MD5 in Ruby 1.9.3 ruby ruby

Digest::MD5 in Ruby 1.9.3


Digest::MD5 is not a method but a module. Try

Digest::MD5.digest("test")


I found it confusing, it doesn't seem like .digest is correct. I can't say it is wrong either...

Commenter @reconbot got it right, IMO, but I saw the comment only after coming back to improve this QA, I think a comment isn't visible enough.

http://ruby-doc.org/stdlib-2.4.0/libdoc/digest/rdoc/Digest/MD5.html

Below is an example usage for md5 hasing for gibbon usage, the mailchimp gem.

md5_hashed_email_address = Digest::MD5.hexdigest("john.doe@example.com")