5

Does anybody know of ruby implementation of RSA Data Security, Inc. MD5 Message-Digest Algorithm defined at https://www.rfc-editor.org/rfc/rfc1321

I found a javascript implementation at https://developer.openx.org/fisheye/browse/openads/branches/2.0/branches/openads-2.0.11/admin/md5.js?r=16584 ... It has a function MD5 which does the encoding. Anything similar on ruby?

1 Answer 1

6

There's plenty of them here

In fact, you're likely to find one using:

require 'digest/md5'
Sign up to request clarification or add additional context in comments.

5 Comments

I checked it out, it doesn't seem to have this particular algorithm.
It very likely does have the bog-standard MD5 algorithm. What do you mean?
The algorithm is below (pasted from javascript code) function MD5(entree) ... for (i=0;i<4;i++) ka+=shl(digestBits[15-i], (i*8)); for (i=4;i<8;i++) kb+=shl(digestBits[15-i], ((i-4)*8)); ... s=hexa(kd)+hexa(kc)+hexa(kb)+hexa(ka); return s; digest/md5 does only md5 encoding. This is more complex.
That extra stuff you've found is just hex-encoding the 128-bit result of the MD5 digest. The real MD5 algorithm is found in the stuff I posted.
and BTW, that code at openx.org is broken - it's only good for 7-bit ASCII, so if your text contains byte values < 32 || > 127 it'll produce non-conformant digests.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.