1 | # MD5
|
2 |
|
3 | [![build status](https://secure.travis-ci.org/pvorb/node-md5.png)](http://travis-ci.org/pvorb/node-md5)
|
4 |
|
5 | a JavaScript function for hashing messages with MD5.
|
6 |
|
7 | **Warning:** This is the source repository for the npm package
|
8 | [MD5](http://search.npmjs.org/#/MD5), not [md5](http://search.npmjs.org/#/md5).
|
9 |
|
10 |
|
11 | ## Installation
|
12 |
|
13 | You can use this package on the server side as well as the client side.
|
14 |
|
15 | ### [Node.js](http://nodejs.org/):
|
16 |
|
17 | ```
|
18 | npm install MD5
|
19 | ```
|
20 |
|
21 |
|
22 | ## API
|
23 |
|
24 | ~~~ javascript
|
25 | md5(message)
|
26 | ~~~
|
27 |
|
28 | * `message` -- `String` or `Buffer`
|
29 | * returns `String`
|
30 |
|
31 |
|
32 | ## Usage
|
33 |
|
34 | ~~~ javascript
|
35 | var md5 = require('MD5');
|
36 |
|
37 | console.log(md5('message'));
|
38 | ~~~
|
39 |
|
40 | This will print the following
|
41 |
|
42 | ~~~
|
43 | 78e731027d8fd50ed642340b7c9a63b3
|
44 | ~~~
|
45 |
|
46 | It supports buffers, too
|
47 |
|
48 | ~~~ javascript
|
49 | var fs = require('fs');
|
50 | var md5 = require('MD5');
|
51 |
|
52 | fs.readFile('example.txt', function(err, buf) {
|
53 | console.log(md5(buf));
|
54 | });
|
55 | ~~~
|
56 |
|
57 |
|
58 | ## Bugs and Issues
|
59 |
|
60 | If you encounter any bugs or issues, feel free to open an issue at
|
61 | [github](https://github.com/pvorb/node-md5/issues).
|
62 |
|
63 |
|
64 | ## Credits
|
65 |
|
66 | This package is based on the work of Jeff Mott, who did a pure JS implementation
|
67 | of the MD5 algorithm that was published by Ronald L. Rivest in 1991. I needed a
|
68 | npm package of the algorithm, so I used Jeff’s implementation for this package.
|
69 | The original implementation can be found in the
|
70 | [CryptoJS](http://code.google.com/p/crypto-js/) project.
|
71 |
|
72 |
|
73 | ## License
|
74 |
|
75 | ~~~
|
76 | Copyright © 2011-2012, Paul Vorbach.
|
77 | Copyright © 2009, Jeff Mott.
|
78 |
|
79 | All rights reserved.
|
80 |
|
81 | Redistribution and use in source and binary forms, with or without modification,
|
82 | are permitted provided that the following conditions are met:
|
83 |
|
84 | * Redistributions of source code must retain the above copyright notice, this
|
85 | list of conditions and the following disclaimer.
|
86 | * Redistributions in binary form must reproduce the above copyright notice, this
|
87 | list of conditions and the following disclaimer in the documentation and/or
|
88 | other materials provided with the distribution.
|
89 | * Neither the name Crypto-JS nor the names of its contributors may be used to
|
90 | endorse or promote products derived from this software without specific prior
|
91 | written permission.
|
92 |
|
93 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
94 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
95 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
96 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
97 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
98 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
99 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
100 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
101 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
102 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
103 | ~~~
|