js-md5
A simple and fast MD5 hash function for JavaScript supports UTF-8 encoding.
Demo
MD5 Online
MD5 File Checksum Online
Download
Compress
Uncompress
Benchmark
jsPerf Benchmark
File Benchmark
Installation
You can also install js-md5 by using Bower.
bower install md5
For node.js, you can use this command to install:
npm install js-md5
Notice
buffer
method is deprecated. This maybe confuse with Buffer in node.js. Please use arrayBuffer
instead.
Usage
You could use like this:
md5('Message to hash');
var hash = md5.create();
hash.update('Message to hash');
hash.hex();
md5.hmac('key', 'Message to hash');
var hash = md5.hmac.create('key');
hash.update('Message to hash');
hash.hex();
Node.js
If you use node.js, you should require the module first:
var md5 = require('js-md5');
TypeScript
If you use TypeScript, you can import like this:
import { md5 } from 'js-md5';
RequireJS
It supports AMD:
require(['your/path/md5.js'], function(md5) {
});
See document
Example
md5('');
md5('The quick brown fox jumps over the lazy dog');
md5('The quick brown fox jumps over the lazy dog.');
md5('中文');
md5([]);
md5(new Uint8Array([]));
md5('');
md5.hex('');
md5.array('');
md5.digest('');
md5.arrayBuffer('');
md5.buffer('');
md5.base64('');
md5.hmac.hex('key', 'Message to hash');
md5.hmac.array('key', 'Message to hash');
License
The project is released under the MIT license.
Contact
The project's website is located at https://github.com/emn178/js-md5
Author: Chen, Yi-Cyuan (emn178@gmail.com)