2012-10-06 06:02:57 -04:00
|
|
|
# encoding: ascii
|
2012-10-04 12:30:56 -04:00
|
|
|
Digest::SHA3.class_eval do
|
|
|
|
def self.hexdigest(*args)
|
2012-10-06 06:02:57 -04:00
|
|
|
force_ascii(digest(*args).unpack("H*").first)
|
2012-10-04 12:30:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def hexdigest
|
2012-10-06 06:02:57 -04:00
|
|
|
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
|