Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Forget about the endians: it's just a way name for a way to encode information.</p> <p>Let's follow the wikipedia <a href="http://en.wikipedia.org/wiki/MD5#Algorithm" rel="nofollow noreferrer">MD5</a> article. You start with an input message. It can be arbitrarily long: MD5 hashes for 2GB ISO files are routinely created, just like hashes for strings a dozen characters long (e.g. for passwords).</p> <p>The hash will be contained in registers <code>a</code> , <code>b</code>, <code>c</code> and <code>d</code>. These registers are initialized with special values (<code>h0-h3</code>).</p> <p>The algorithm breaks the input into 16 4-byte chunks ("sixteen 32-bit little-endian words") and applies specific logical operations (functions <code>F</code>, <code>G</code>, <code>H</code> and <code>I</code>) on parts of the input and the current state of registers <code>a</code> , <code>b</code>, <code>c</code> and <code>d</code>. It does this 64 times for each set of 16 4-byte chunks.</p> <p>When all of the chunks are processed, what remains in <code>a</code> , <code>b</code>, <code>c</code> and <code>d</code> is the final hash, the one you might get by invoking <code>md5sum testfile.txt</code>.</p> <p>Update:</p> <p>If you just want to be able to calculate a hash, implementing it yourself makes no sense because it's been done and tested for probably every significant language out there:</p> <p><a href="http://docs.python.org/library/md5.html" rel="nofollow noreferrer">Python</a>:</p> <pre><code>import md5 md5.new("Nobody inspects the spammish repetition").digest() </code></pre> <p>SQL (<a href="http://dev.mysql.com/doc/refman/5.1/en/encryption-functions.html#function_md5" rel="nofollow noreferrer">MySQL</a>):</p> <pre><code>SELECT MD5('Nobody inspects the spammish repetition') </code></pre> <p><a href="http://snippets.dzone.com/posts/show/3686" rel="nofollow noreferrer">Java</a>:</p> <pre><code>String s="Nobody inspects the spammish repetition"; MessageDigest m=MessageDigest.getInstance("MD5"); m.update(s.getBytes(),0,s.length()); System.out.println(new BigInteger(1,m.digest()).toString(16)); </code></pre> <p>etc.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload