PHP to Ruby
Convert PHP code into Ruby!
-
sha1
Posted on May 8th, 2009 No commentsThe sha1() function calculates the sha1 hash of a string.
PHP
echo sha1('apple'); // => d0be2dc421be4fcd0172e5afceea3970e2f3d940
Sha1 encryption can be done using the Digest::SHA1 class in Ruby. To use this class, we need to require the Digest library first…
Ruby
require 'digest/sha1'; print Digest::SHA1.hexdigest('apple'); # => d0be2dc421be4fcd0172e5afceea3970e2f3d940
Leave a reply


