npm系列:md5 ---- 一个用于生成MD5哈希值的Node.js模块

md5 - npm (npmjs.com)

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)
  • messageString, Buffer, Array or Uint8Array
  • 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项目中找到

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值