You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Include the (minified) JavaScript [MD5](http://en.wikipedia.org/wiki/MD5) script in your HTML markup:
10
+
11
+
```html
12
+
<scriptsrc="md5.min.js"></script>
13
+
```
14
+
15
+
In your application code, calculate the ([hex](http://en.wikipedia.org/wiki/Hexadecimal)-encoded) [MD5](http://en.wikipedia.org/wiki/MD5) hash of a string by calling the **md5** method with the string as argument:
16
+
17
+
```js
18
+
var hash =md5("value"); // "2063c1608d6e0baf80249c42e2be5804"
19
+
```
20
+
21
+
### Server-side
22
+
23
+
The following is an example how to use the JavaScript MD5 module on the server-side with [node.js](http://nodejs.org/).
24
+
25
+
Create a new directory and add the **md5.js** file. Or alternatively, install the **blueimp-md5** package with [npm](http://npmjs.org/):
26
+
27
+
```sh
28
+
npm install blueimp-md5
29
+
```
30
+
31
+
Add a file **server.js** with the following content:
// Calculate and print the MD5 hash of the url query:
43
+
res.end(md5(query));
44
+
}).listen(8080, "localhost");
45
+
console.log("Server running at http://localhost:8080/");
46
+
```
47
+
48
+
Run the application with the following command:
49
+
50
+
```sh
51
+
node server.js
52
+
```
53
+
54
+
## Requirements
55
+
The JavaScript MD5 script has zero dependencies.
56
+
57
+
## API
58
+
59
+
Calculate the ([hex](http://en.wikipedia.org/wiki/Hexadecimal)-encoded) [MD5](http://en.wikipedia.org/wiki/MD5) hash of a given string value:
60
+
61
+
```js
62
+
var hash =md5("value"); // "2063c1608d6e0baf80249c42e2be5804"
63
+
```
64
+
65
+
Calculate the ([hex](http://en.wikipedia.org/wiki/Hexadecimal)-encoded) [HMAC](http://en.wikipedia.org/wiki/HMAC)-MD5 hash of a given string value and key:
66
+
67
+
```js
68
+
var hash =md5("value", "key"); // "01433efd5f16327ea4b31144572c67f6"
69
+
```
70
+
71
+
Calculate the raw [MD5](http://en.wikipedia.org/wiki/MD5) hash of a given string value:
72
+
73
+
```js
74
+
var hash =md5("value", null, true);
75
+
```
76
+
77
+
Calculate the raw [HMAC](http://en.wikipedia.org/wiki/HMAC)-MD5 hash of a given string value and key:
78
+
79
+
```js
80
+
var hash =md5("value", "key", true);
81
+
```
82
+
83
+
## License
84
+
The JavaScript MD5 script is released under the [MIT license](http://creativecommons.org/licenses/MIT/).
Compatible with server-side environments like <ahref="http://nodejs.org/">node.js</a>, module loaders like <ahref="http://requirejs.org/">RequireJS</a> and all web browsers.</p>
0 commit comments