JavaScript-MD5

JavaScript MD5 implementation. Compatible with server-side environments like node.js, module loaders like RequireJS and all web browsers.

  • 所有者: blueimp/JavaScript-MD5
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

JavaScript MD5

Contents

Demo

JavaScript MD5 Demo

Description

JavaScript MD5 implementation. Compatible with server-side environments like
Node.js, module loaders like RequireJS, Browserify or webpack and all web
browsers.

Usage

Client-side

Include the (minified) JavaScript MD5
script in your HTML markup:

<script src="js/md5.min.js"></script>

In your application code, calculate the
(hex-encoded)
MD5 hash of a string by calling the md5
method with the string as argument:

var hash = md5('value') // "2063c1608d6e0baf80249c42e2be5804"

Server-side

The following is an example how to use the JavaScript MD5 module on the
server-side with Node.js.

Create a new directory and add the md5.js file. Or alternatively, install
the blueimp-md5 package with npm:

npm install blueimp-md5

Add a file server.js with the following content:

require('http')
  .createServer(function(req, res) {
    // The md5 module exports the md5() function:
    var md5 = require('./md5'),
      // Use the following version if you installed the package with npm:
      // var md5 = require("blueimp-md5"),
      url = require('url'),
      query = url.parse(req.url).query
    res.writeHead(200, { 'Content-Type': 'text/plain' })
    // Calculate and print the MD5 hash of the url query:
    res.end(md5(query))
  })
  .listen(8080, 'localhost')
console.log('Server running at http://localhost:8080/')

Run the application with the following command:

node server.js

Requirements

The JavaScript MD5 script has zero dependencies.

API

Calculate the (hex-encoded)
MD5 hash of a given string value:

var hash = md5('value') // "2063c1608d6e0baf80249c42e2be5804"

Calculate the (hex-encoded)
HMAC-MD5 hash of a given string value and
key:

var hash = md5('value', 'key') // "01433efd5f16327ea4b31144572c67f6"

Calculate the raw MD5 hash of a given
string value:

var hash = md5('value', null, true)

Calculate the raw HMAC-MD5 hash of a given
string value and key:

var hash = md5('value', 'key', true)

Tests

The JavaScript MD5 project comes with
Unit Tests.
There are two different ways to run the tests:

  • Open test/index.html in your browser or
  • run npm test in the Terminal in the root path of the repository package.

The first one tests the browser integration, the second one the
node.js integration.

License

The JavaScript MD5 script is released under the
MIT license.

主要指标

概览
名称与所有者blueimp/JavaScript-MD5
主编程语言JavaScript
编程语言JavaScript (语言数: 4)
平台
许可证MIT License
所有者活动
创建于2011-12-10 20:42:25
推送于2021-09-25 14:53:13
最后一次提交2021-09-25 23:48:43
发布数29
最新版本名称v2.19.0 (发布于 2021-09-25 23:44:08)
第一版名称1.0.1 (发布于 )
用户参与
星数4.6k
关注者数115
派生数1.7k
提交数96
已启用问题?
问题数14
打开的问题数2
拉请求数2
打开的拉请求数0
关闭的拉请求数22
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?