MD5 Online Calculator and Library

Updated 2011-06-19 by Luigi Galli

Warning!

» Versions prior to 0.2 (2011-05-22) contain an integer overflow bug which can lead to wrong results, please update your library!

» Some browsers insert extra line breaks in the text which is pasted/typed in the GUI's textarea element. Favor calling the library directly instead of using the GUI when handling larger chunks of text


Calculator

This is an online text to MD5 hash calculator/digester. It uses a pure Javascript implementation of the MD5 hash function and runs entirely in the browser, nothing is sent to the server. It is therefore safe for rapid password to hash conversions. The Javascript MD5 source is free to download and may be used in any type of application. See details below.

Note: this GUI version assumes Unicode code points are encoded as UTF-8. If you attempt to digest Unicode strings using other encodings you will get incorrect results! Use the MD5 function directly passing an array of bytes as argument if you need to digest anything else than ASCII or UTF-8 text.

Result:


MD5 Library

The Javascript MD5 library source code is released as public domain and can be downloaded here:

Simply call the faultylabs.MD5("text to digest") function passing the data to digest as argument to get the MD5 hash returned as hex (uppercase) string. Input data can be of any of the following types :

The input data type is automatically detected. The function works on most modern browsers (but also IE6) and performs well even when fed a relatively large (several KB's) data set.

Example:

<script type="text/javascript" src="md5.js"></script>
<script type="text/javascript" >
// quick test
var input1 = "ABC";
var input2 = ["A","B","C"];
var input3 = [0x41, 0x42, 0x43];
alert(faultylabs.MD5(input1) == "902FBDD2B1DF0C4F70B4A5D23525E932");
alert(faultylabs.MD5(input2) == "902FBDD2B1DF0C4F70B4A5D23525E932");
alert(faultylabs.MD5(input3) == "902FBDD2B1DF0C4F70B4A5D23525E932");

// ArrayBuffer
var abuf = new ArrayBuffer(3)
var vu8  = new Uint8Array(abuf)
vu8[0] = 0x41; vu8[1] = 0x42; vu8[2] = 0x43
alert(faultylabs.MD5(abuf) == "902FBDD2B1DF0C4F70B4A5D23525E932")

// Typed Array Uint32Array
var au32  = new Uint32Array(1)
au32[0] = 0xDDCCBBAA 
alert(faultylabs.MD5(au32) == "CA6FFBF95B47864FD4E73F2601326304")

</script>

Changelog

    Version 0.4   - 2011-06-19
    + added compact version (md5_compact_min.js), this is a slower but smaller version 
      (more than 4KB lighter before stripping/minification)
    + added preliminary support for Typed Arrays (see: 
      https://developer.mozilla.org/en/JavaScript_typed_arrays and 
      http://www.khronos.org/registry/typedarray/specs/latest/)
      MD5() now accepts input data as ArrayBuffer, Float32Array, Float64Array, 
      Int16Array, Int32Array, Int8Array, Uint16Array, Uint32Array or Uint8Array 
    - moved unit tests to md5_test.js
    - minor refactoring 

    Version 0.3.* - 2011-06-##
    - Internal dev versions

    Version 0.2 - 2011-05-22 
    ** FIXED: serious integer overflow problems which could cause a wrong MD5 hash being returned

    Version 0.1 - 2011
    -Initial version