Convert PHP code into Ruby!
RSS icon Email icon Home icon
  • md5

    Posted on May 5th, 2009 RubyLove No comments

    The md5() function calculates the md5 hash of a string.

    PHP

    echo md5('apple');
    // => 1f3870be274f6c49b3e31a0c6728957f

    MD5 encryption can be done using the Digest library in Ruby. To use the Digest library, just require it…

    Ruby

    require 'digest/md5';
     
    print Digest::MD5.hexdigest('apple');
     
    # => 1f3870be274f6c49b3e31a0c6728957f

    Leave a reply