digest-keccak/lib/digest/sha3/helpers.rb

21 lines
383 B
Ruby
Raw Normal View History

# encoding: ascii
2012-10-04 12:30:56 -04:00
Digest::SHA3.class_eval do
def self.hexdigest(*args)
force_ascii(digest(*args).unpack("H*").first)
2012-10-04 12:30:56 -04:00
end
def hexdigest
Digest::SHA3.force_ascii(digest.unpack("H*").first)
end
if ''.respond_to?(:force_encoding)
def self.force_ascii(str)
str.force_encoding('ascii')
end
else
def self.force_ascii(str)
str
end
2012-10-04 12:30:56 -04:00
end
end