Converting a hexadecimal digest to base64 in Ruby Converting a hexadecimal digest to base64 in Ruby ruby ruby

Converting a hexadecimal digest to base64 in Ruby


Seems pretty clear and efficient to me. You can save the call to strip by specifying 0 count for the 'm' pack format (if count is 0, no line feed are added, see RFC 4648)

def hex_to_base64_digest(hexdigest)  [[hexdigest].pack("H*")].pack("m0")end