HTML Data Port

© 2005 Goetz Heller

Table of Contents Description Source Code Copyright Note back

The MD4 Hash Algorithm - Examples

      document.write('<'+'h4><'+'em>Run Tests From RFC1320:<'+'/em><'+'/h4>');
      var md4 = core.createInstance('system.security.encryption.hash.MD4');
      var inp = [
        "",
        "a",
        "abc",
        "message digest",
        "abcdefghijklmnopqrstuvwxyz",
        "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
        "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
      ];
      for (var j = 0; j < inp.length; j++) {
        var d = md4.computeHash(inp[j]);
        var s = '';
        for (var i = 0; i < d.length; i++) {
          s += ((d.charCodeAt(i) < 16) ? '0' : '') + d.charCodeAt(i).toString(16);
        }
        document.write('md4.computeHash(\''+inp[j]+'\') = \'' + s +'\'<'+'br/>');
      }