How to get hex of string in SHA-0 in ruby >=1.9.3?
I searched on GitHub and here, I looked at the module Digest
, but couldn't find an answer.
There are lot of crypto methods in the OpenSSL module, including SHA. (SHA was later named SHA0)
http://ruby-doc.org/stdlib-1.9.3/libdoc/openssl/rdoc/OpenSSL/Digest.html
require 'openssl'
digest_maker = OpenSSL::Digest::SHA.new
digest = digest_maker.digest( 'your_message_here' )
You can convert the digest to hex with unpack:
hex_digest = digest.unpack('H*')
hex_digest[0] # because array is returned by unpack