What is js-md4?
The js-md4 package is a JavaScript implementation of the MD4 message digest algorithm. This package allows for the hashing of strings using the MD4 algorithm, which is a cryptographic hashing function. Although MD4 is considered to be broken and vulnerable for cryptographic purposes, this package can still be used for legacy systems or non-security-critical applications where MD4 hashing is required.
What are js-md4's main functionalities?
MD4 Hashing of Strings
This feature allows users to hash strings using the MD4 algorithm. The code sample demonstrates how to hash the string 'string to hash' and log the result to the console.
"use strict";
const md4 = require('js-md4');
console.log(md4('string to hash'));
Other packages similar to js-md4
md5
The md5 package is a JavaScript implementation of the MD5 message digest algorithm. Similar to js-md4, it allows for the hashing of strings but using the MD5 algorithm instead. MD5 is more widely used than MD4 and is considered to be more secure, although it also has known vulnerabilities and is not recommended for cryptographic security purposes.
sha1
The sha1 package provides a JavaScript implementation of the SHA-1 hashing algorithm. Unlike js-md4, which uses the MD4 algorithm, sha1 uses SHA-1, which is a more secure hashing algorithm but also has been found to have vulnerabilities. This package is used for hashing strings in a similar manner to js-md4 but with a different underlying algorithm.
crypto-js
Crypto-js is a collection of cryptography algorithms implemented in JavaScript. It offers a wide range of cryptographic functions including MD4, MD5, SHA-1, SHA-256, and more. Compared to js-md4, crypto-js provides a more comprehensive suite of cryptographic tools, making it a versatile choice for projects requiring various cryptographic functionalities.
js-md4
A simple MD4 hash function for JavaScript supports UTF-8 encoding.
Demo
MD4 Online
Download
Compress
Uncompress
Installation
You can also install js-md4 by using Bower.
bower install js-md4
For node.js, you can use this command to install:
npm install js-md4
Notice
buffer
method is deprecated. This maybe confuse with Buffer in node.js. Please use arrayBuffer
instead.
Usage
You could use like this:
md4('Message to hash');
var hash = md4.create();
hash.update('Message to hash');
hash.hex();
var hash2 = md4.update('Message to hash');
hash2.update('Message2 to hash');
hash2.array();
If you use node.js, you should require the module first:
var md4 = require('js-md4');
It supports AMD:
require(['your/path/md4.js'], function (md4) {
});
See document
Example
md4('');
md4('The quick brown fox jumps over the lazy dog');
md4('The quick brown fox jumps over the lazy dog.');
md4('中文');
md4([]);
md4(new Uint8Array([]));
md4('');
md4.hex('');
md4.array('');
md4.digest('');
md4.arrayBuffer('');
License
The project is released under the MIT license.
Contact
The project's website is located at https://github.com/emn178/js-md4
Author: Chen, Yi-Cyuan (emn178@gmail.com)