I have faced a problem to understand MD5 algorithm.My question is weather the original input message is converted to binary value in MD5 before using the input message as parameter in four Feistel permutations FF,GG,HH and KK?

In order to understand my question here is an example. If the original input message is 'amrasobaiatel' my question is that weather the message is converted to binary value such as '00010000000000' before padding and appending the 64-representation of the length of the input message?

If the answer of my question is 'yes' then my another question is that how can we convert the original input message into binary value?

  • 1
    $\begingroup$ This question belongs to StackOverflow. Both of your questions are programming related. You can input a byte array to your function and you can convert anything to byte array. Therefore I'm voting to migrate this question to StackOverflow. $\endgroup$ – Aventinus Feb 17 '16 at 4:55
  • $\begingroup$ I think that - especially after the edit by otus - that the question is actually OK for this site. At SO you'd expect a runtime tag or similar. $\endgroup$ – Maarten Bodewes Feb 17 '16 at 9:56

MD5, like most cryptographical algorithms, takes inputs which are strings of bytes (actually, bits, however we rarely need to hash an arbitrary bitstring). So, yes, to hash a string with MD5, you need to convert that string into a series of bytes somehow.

As for how you do that, well, for a string like 'amrasobalatel', the most common transform is to take the ASCII encoding of that string; however there's no reason you couldn't use UTF-16 or EBCDIC...

  • 1
    $\begingroup$ It might be noted that the Bit String to Octet String conversion in MD5 uses Big Endian bit order, despite the Octet String to Word conversion within MD5 uses a Little Endian byte order. The RFC is a cautionary example of an under-specified algorithm specification. $\endgroup$ – Henrick Hellström Feb 17 '16 at 9:23
  • $\begingroup$ Note that the internal representation of "amrasobaiatel" may already be in a default character format. Many languages such as C but also PHP etc. allow you to directly address this internal representation as bytes (a char in C is actually a byte). In that case you may not need to encode the string (assuming that the system uses the required encoding of course). You should however have a strong preference to always encoding to a specific character set, with UTF-8 as main contender. $\endgroup$ – Maarten Bodewes Feb 17 '16 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.