GithubHelp home page GithubHelp logo

shakakira / javascript-md5 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from blueimp/javascript-md5

0.0 1.0 0.0 73 KB

JavaScript MD5 implementation

Home Page: http://blueimp.github.com/JavaScript-MD5/

javascript-md5's Introduction

JavaScript MD5

Demo

JavaScript MD5 Demo

Usage

Client-side

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

<script src="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").md5,
    // Use the following version if you installed the package with npm:
    // var md5 = require("blueimp-md5").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);

License

The JavaScript MD5 script is released under the MIT license.

javascript-md5's People

Contributors

blueimp avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.