js-md4: MD4 Hash Function

0.3.2 · abandoned · verified Sun Apr 19

js-md4 is a JavaScript library providing a pure JavaScript implementation of the MD4 cryptographic hash function. Currently at version 0.3.2, its last known release was over eight years ago, indicating it is an abandoned project with no ongoing maintenance or updates. The library supports UTF-8 encoding for input strings and can process various data types, including JavaScript strings, raw byte `Array`s, `Uint8Array`s, and `ArrayBuffer`s. It offers both a direct hashing function for immediate results and an incremental hashing API via a `create()` method, allowing for data to be fed in chunks. Output formats include hexadecimal strings, byte arrays, and ArrayBuffers. Key differentiators at the time of its release were its pure JavaScript nature, broad browser compatibility (via script tag and AMD), and Node.js support (via CommonJS). Given the long period of inactivity and the known cryptographic weaknesses of MD4 itself, this library is primarily suitable for compatibility with legacy systems or non-security-critical hashing tasks.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates both direct and incremental MD4 hashing with various input and output types, including UTF-8 strings.

const md4 = require('js-md4');

// Basic one-shot hashing
const hash1 = md4('Message to hash');
console.log(`Direct hash: ${hash1}`);

// Hashing with specific output format (hexadecimal is default for direct string input)
const hash2Hex = md4.hex('Another message');
console.log(`Hex output: ${hash2Hex}`);

const hash3Array = md4.array('Bytes output');
console.log(`Array output: ${hash3Array}`);

// Incremental hashing
const hasher = md4.create();
hasher.update('Part one of ');
hasher.update('the message');
const finalHash = hasher.hex();
console.log(`Incremental hash: ${finalHash}`);

// Hashing a UTF-8 string
const utf8Hash = md4('你好世界');
console.log(`UTF-8 hash: ${utf8Hash}`);

view raw JSON →