> Hi guys !
>
> I need some help with a little problem I have with MD5 hashs.
>
> I need to be able to convert existing MD5 hexdigests to raw digests. Is
> this possible?
>
> I'll explain.
>
> If I do : Digest::MD5.digest('password'), I get a raw MD5 digest. Right.
>
> Then if I do : Digest::MD5.digest('password').unpack("H*")[0], then I
> get the same output that if I did Digest::MD5.hexdigest('password').
>
> But how can I do the opposite in ruby? How can I go from an existing
> hexdigested MD5 string to the raw form?

Hi,

the inverse operation of String#unpack is Array#pack. So all you need
to do is wrap your hex String in an Array first:

bytes = [hex].pack("H*")

Regards,
Martin

PS: As far as I remember, Digest also implements #hexdigest, at least
OpenSSL::Digest does. This would save you some typing for the first
case :)