UNPKG

2.93 kBMarkdownView Raw
1# MD5
2
3[![build status](https://secure.travis-ci.org/pvorb/node-md5.png)](http://travis-ci.org/pvorb/node-md5)
4
5a 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
13You can use this package on the server side as well as the client side.
14
15### [Node.js](http://nodejs.org/):
16
17```
18npm install MD5
19```
20
21
22## API
23
24~~~ javascript
25md5(message)
26~~~
27
28 * `message` -- `String` or `Buffer`
29 * returns `String`
30
31
32## Usage
33
34~~~ javascript
35var md5 = require('MD5');
36
37console.log(md5('message'));
38~~~
39
40This will print the following
41
42~~~
4378e731027d8fd50ed642340b7c9a63b3
44~~~
45
46It supports buffers, too
47
48~~~ javascript
49var fs = require('fs');
50var md5 = require('MD5');
51
52fs.readFile('example.txt', function(err, buf) {
53 console.log(md5(buf));
54});
55~~~
56
57
58## Bugs and Issues
59
60If 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
66This package is based on the work of Jeff Mott, who did a pure JS implementation
67of the MD5 algorithm that was published by Ronald L. Rivest in 1991. I needed a
68npm package of the algorithm, so I used Jeff’s implementation for this package.
69The original implementation can be found in the
70[CryptoJS](http://code.google.com/p/crypto-js/) project.
71
72
73## License
74
75~~~
76Copyright © 2011-2012, Paul Vorbach.
77Copyright © 2009, Jeff Mott.
78
79All rights reserved.
80
81Redistribution and use in source and binary forms, with or without modification,
82are 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
93THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
94ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
95WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
96DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
97ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
98(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
99LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
100ANY 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
102SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
103~~~