MD5
a JavaScript function for hashing messages with MD5.
一个使用MD5对消息进行哈希处理的JavaScript函数。
Installation
You can use this package on the server side as well as the client side.
您可以在服务器端和客户端都使用这个包。
Node.js:
npm install md5
API
md5(message)
message
–String
,Buffer
,Array
orUint8Array
- returns
String
Usage
var md5 = require('md5');
console.log(md5('message'));
This will print the following
这将打印出以下内容:
78e731027d8fd50ed642340b7c9a63b3
It supports buffers, too
它还支持缓冲区:
var fs = require('fs');
var md5 = require('md5');
fs.readFile('example.txt', function(err, buf) {
console.log(md5(buf));
});
Versions
Before version 2.0.0 there were two packages called md5 on npm, one lowercase, one uppercase (the one you’re looking at). As of version 2.0.0, all new versions of this module will go to lowercase md5 on npm. To use the correct version, users of this module will have to change their code from require('MD5')
to require('md5')
if they want to use versions >= 2.0.0.
在2.0.0版本之前,npm上有两个名为md5的包,一个为小写,一个大写(您正在查看的这个)。从2.0.0版本开始,此模块的所有新版本都将在npm上以小写md5的形式发布。要使用正确版本,此模块的用户如果希望使用>=2.0.0的版本,则需要将代码从require('MD5')
更改为require('md5')
。
Bugs and Issues
错误和问题
If you encounter any bugs or issues, feel free to open an issue at github.
如果您遇到任何错误或问题,请随时在github上开一个issue。
Credits
致谢
This package is based on the work of Jeff Mott, who did a pure JS implementation of the MD5 algorithm that was published by Ronald L. Rivest in 1991. I needed a npm package of the algorithm, so I used Jeff’s implementation for this package. The original implementation can be found in the CryptoJS project.
此包基于Jeff Mott的工作,他实现了一个纯JS的MD5算法,该算法由Ronald L. Rivest于1991年发布。我需要一个npm包来实现这个算法,所以我使用了Jeff的实现来创建这个包。原始实现可以在CryptoJS项目中找到