md5
-
In PHP, we use the
md5function to calculate an MD5 hash. In Ruby, we use theDigest::MD5class. We first need to require theDigestlibrary usingrequire "digest". This is similar to usingrequire_onceto include a class in PHP. To get the equivalent of the hash we’d generate usingmd5(), we use thehexdigestmethod.PHP
print md5("my string"); // => 2ba81a47c5512d9e23c435c1f29373cb
Ruby
require "digest" print Digest::MD5.hexdigest("my string") # => 2ba81a47c5512d9e23c435c1f29373cb
see also
Looking for Rails or PHP web application development, integration, and training?
Rails for PHP is brought to you by Maintainable Software. Get custom web applications and personalized training from the authors of the book and website.

