JavaScript MD5
This is fork from blueimp, rewritten in es6, and added rollup + babel in build.
Demo
Description
JavaScript MD5 implementation. Compatible with server-side environments like Node.js, module loaders like RequireJS, Browserify or webpack and all web browsers.
Usage
Client-side
Include the (minified) JavaScript MD5 script in your HTML markup:
In your application code, calculate the (hex-encoded) MD5 hash of a string by calling the md5 method with the string as argument:
var hash = ; // "2063c1608d6e0baf80249c42e2be5804"
in es6 imports
In crc/md5
folder still available raw es6 source, without babel/rollup.
You can use them in your projects, when raw es6 is required.
; var hash = ; // "2063c1608d6e0baf80249c42e2be5804"
Server-side
The following is an example how to use the JavaScript MD5 module on the server-side with Node.js.
Create a new directory and add the md5.js file. Or alternatively, install the blueimp-md5 package with npm:
npm install blueimp-md5-es6
Add a file server.js with the following content:
;console;
Run the application with the following command:
node server.js
Requirements
The JavaScript MD5 script has zero dependencies.
API
Calculate the (hex-encoded) MD5 hash of a given string value:
var hash = ; // "2063c1608d6e0baf80249c42e2be5804"
Calculate the (hex-encoded) HMAC-MD5 hash of a given string value and key:
var hash = ; // "01433efd5f16327ea4b31144572c67f6"
Calculate the raw MD5 hash of a given string value:
var hash = ;
Calculate the raw HMAC-MD5 hash of a given string value and key:
var hash = ;
Tests
The JavaScript MD5 project comes with
Unit Tests.
There are two different ways to run the tests:
- Open test/index.html in your browser or
- run
npm test
in the Terminal in the root path of the repository package.
The first one tests the browser integration, the second one the node.js integration.
License
The JavaScript MD5 script is released under the MIT license.