From: Shuaib Zahda on
Hi there

I am trying to compute the 16 octet MD5 hash.
I looked in the digest/md5 and i could not figure it out.
i used Digest::MD5.hexdigest(value)
but this computes 32 if I am not mistaken.

Any idea please?
--
Posted via http://www.ruby-forum.com/.

From: Michael Fellinger on
On Mon, Apr 19, 2010 at 3:26 AM, Shuaib Zahda <shuaib.zahda(a)gmail.com> wrote:
> Hi there
>
> I am trying to compute the 16 octet MD5 hash.
> I looked in the digest/md5 and i could not figure it out.
> i used Digest::MD5.hexdigest(value)
> but this computes 32 if I am not mistaken.
>
> Any idea please?

MD5 computes a 128bit hash.
If you use MD5.hexdigest, you will get a String representation in base
16, so it's 32 octets.
You could use MD5.digest instead, which returns a String in base 255,
that means it's 16 octets.

--
Michael Fellinger
CTO, The Rubyists, LLC

From: Shuaib Zahda on
Michael Fellinger wrote:

>
> MD5 computes a 128bit hash.
> If you use MD5.hexdigest, you will get a String representation in base
> 16, so it's 32 octets.
> You could use MD5.digest instead, which returns a String in base 255,
> that means it's 16 octets.

Michael thank you very much, you saved me a lot of time. It took me
hours to find this out and now my application is working

thanks a lot
--
Posted via http://www.ruby-forum.com/.