MD5 16 octet - how to compute?

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?

Michael F. 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

On Mon, Apr 19, 2010 at 3:26 AM, Shuaib Z. [email protected]
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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs