Thursday, September 6, 2007

Ruby hexdigest to digest


# Translating back from hexdigest to digest. Useful when you
# have used Digest::SHA1.hexdigest and change your mind.

def hexdigest_to_digest(h)
h.unpack('a2'*(h.size/2)).collect {|i| i.hex.chr }.join
end

No comments: