You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
3.1 KiB

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