MD5 is a digital signature / "message digest" algorithm for security verification and secure authentication without encryption.
The purpose of the MD5 JavaScript speed test is to evaluate performance of MD5 JavaScript implementations. It is also a useful testcase for general analysis of a given scripting engine.
Functions tested: MD5() / hex_md5() Paul Johnston (MD5() used at Yahoo! Mail login), MD5_hexhash()* Masanao Izumo, and md5() Joseph Myers (optimized). (*doesn't work on IE on Macintosh.)
The test uses an automatic judgment algorithm to limit the length of tests so slow computers do not freeze during a test configured for a faster computer. This consists of MD5 calculations of five basic inputs:
| input | correct MD5 signature |
|---|---|
| "", the null string | d41d8cd98f00b204e9800998ecf8427e |
| "hello\n", five bytes plus linefeed | b1946ac92492d2347c6235b4d2611184 |
| " ", a single space | 7215ee9c7d9dc229d2921a40e899ec5f |
| "HTML", four bytes | 4c4ad5fca2e7a3f74dbb1ced00381aa4 |
| A-Za-z0-9+/, list of the sixty-four Base64 alphabet characters | 7845f7eade89338adabfef89bd6e9a5b |
The test may be run from any known MD5 JavaScript code. The default is to show the results for common browsers and platforms.
| Platform | Time |
|---|---|
| Opera 9.23 / Windows Vista Ultimate, AMD X2 4000+ (2.1 GHz dual core) | jkm = 116,213 B/s, paj = 89,087, mi = 89,825. |
| Mozilla 1.3 / Mac | jkm = 3066 B/s, paj = 1852, mi = 2732. |
| IE 6 / Windows XP | jkm = 19053 B/s, paj = 16125 B/s, mi = 17881 B/s. |
| IE 6 / Windows 98 (another computer) | jkm = 9327 B/s, paj = 5618 B/s, mi = 5020 B/s. |
| IE 5.2.3 / Mac OS X 10.2.6 (6-16-03) | jkm = 7769 B/s, paj = 4213 (note: 263-byte test was fastest), mi = 4068 (this with incorrect checksum). (Each was best of two.) |
| IE 5 / Mac OS 9.2.2 | jkm = 7570 B/s, paj = 4064, mi = 4068 (with incorrect checksum). |
| Netscape Communicator 4.77 / Mac OS 9.2.2 | jkm = 5089 B/s, paj = 3535, mi = 5429. |
| Camino 7.0+ (nightly on 11-12-03) / Mac OS 10.2.8; best results of two | jkm = 7721 B/s, paj = 4339, mi = 6286. |
| Camino 0.8b (5-22-04) / Mac OS 10.2.8; best results of two | jkm = 7471 B/s, paj = 4096, mi = 6247. |
| Safari Beta 2 / Mac OS 10.2.5 | jkm = 1076 B/s, paj = 1044, mi = 1126. |
| Mozilla Firebird 0.6 / Mac OS X 10.2.6 | jkm = 5576 B/s, paj = 3455, mi = 4840. |
| Opera 6.02 / Mac OS 10.2.6 | jkm = 1084 B/s, paj = 925, mi = 1125* (*checksum failed). |
| Opera 7.50 / Mac OS 10.2.8 (5-18-04, best of two) | jkm = 1966 B/s, paj = 1849, mi = 2160. |
| Safari 1.0 (6-23-03, best of two) | jkm = 1460 B/s, paj = 1062, mi = 1304. |
| Mozilla 1.7a (1-16-04, best of two) | jkm = 5577 B/s, paj = 3310, mi = 4786. |
| Firefox 0.8 (2-9-04, best of two) | jkm = 6089 B/s, paj = 3685, mi = 4516. |
| Firefox 0.9 (6-17-04, best of two) | jkm = 5909 B/s, paj = 3481, mi = 5330. |
| Camino 0.8 (7-3-04, best of two) | jkm = 7880 B/s, paj = 4245, mi = 6545. |
| Firefox 0.9.1 (7-4-04, best of two) | jkm = 5918 B/s, paj = 3486, mi = 4538. |
jkm = md5 by Joseph Myers, paj = hex_MD5 by Paul Johnston, mi = MD5_hexhash by Masanao Izumo.
Choose a link to test known MD5 implementations: md5 by Joseph Myers, MD5 by Paul Johnston, MD5 by Masanao Izumo.
For historical interest, there is also calcMD5 by Henri Torgemane. Unfortunately, it is written in 1996 and had to be modified somewhat to use local iteration variables; due to other similar artifacts of early JavaScript implementation (all the way back to .jvs), its performance on Mozilla Firefox 0.9 is 338 ms, compared to 29 ms for jkm-md5. Also, it does not pass the calculation for the MD5 sum of "hello\n" (test 2/5), but this is merely due to its ASCII-isation, presumably, which is arguably 50% a feature and 50% not a feature. (Some would say that another function should do that job--not the MD5 calculation.)