Skip to content

Commit

Permalink
* Improve performance.
Browse files Browse the repository at this point in the history
* Add bower package.
* Fixed JSHint warnings.
* Add travis.
* Add coveralls.
  • Loading branch information
emn178 committed Jan 5, 2015
1 parent fc26dd2 commit b31e43e
Show file tree
Hide file tree
Showing 14 changed files with 353 additions and 162 deletions.
1 change: 1 addition & 0 deletions .covignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/tests/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
covreporter
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: node_js
node_js:
- "0.11"
- "0.10"
- "0.8"
- "0.6"
install:
- npm install coveralls -g
- npm install mocha-lcov-reporter -g
script:
- npm run-script coveralls
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# v0.1.3 / 2015-01-05

* Improve performance.
* Add bower package.
* Fixed JSHint warnings.
* Add travis.
* Add coveralls.

# v0.1.2 / 2014-07-27

Fixed accents bug
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2014 [email protected]
Copyright 2014-2015 [email protected]

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
51 changes: 37 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,54 @@
# js-md5
A simple MD5 hash function for JavaScript supports UTF-8 encoding.
[![Build Status](https://api.travis-ci.org/emn178/js-md5.png)](https://travis-ci.org/emn178/js-md5)
[![NPM](https://nodei.co/npm/js-md5.png?stars&downloads)](https://nodei.co/npm/js-md5/)

## Demo
[MD5 Online](http://emn178.github.io/online-tools/md5.html)

## Download
[Compress](https://raw.github.com/emn178/js-md5/master/build/md5.min.js)
[Uncompress](https://raw.github.com/emn178/js-md5/master/src/md5.js)

## Install
You can also install js-md5 by using Bower.

bower install js-md5

For node.js, you can use this command to install:

npm install js-md5

## Usage
If you use node.js, you should require the module first:
You could use like this:
```JavaScript
md5 = require('js-md5');
md5('Message to hash');
```
And you could use like this:
If you use node.js, you should require the module first:
```JavaScript
md5('Message to hash');
md5 = require('js-md5');
```

### Methods

#### md5(str, asciiOnly)

Hash string to md5, set asciiOnly to true for better performace if you ensure input is ascii.

##### *str: `String`*

String to hash.

##### *asciiOnly: `Boolean` (default: `false`)*

Specify the string encoding is ASCII.

## Example
Code
```JavaScript
md5('');
md5('The quick brown fox jumps over the lazy dog');
md5('The quick brown fox jumps over the lazy dog.');
md5('The quick brown fox jumps over the lazy dog', true);
md5('The quick brown fox jumps over the lazy dog.', true);
```
Output

Expand All @@ -38,14 +66,9 @@ Output

a7bac2239fcdcb3a067903d8077c4a07

## Tests
You can open `tests/index.html` in browser or use node.js to run test

node tests/node-test.js

or

npm test
## Benchmark
[ASCII](http://jsperf.com/md5-ascii/3)
[UTF8](http://jsperf.com/md5-utf8)

## Extensions
### jQuery
Expand Down
9 changes: 9 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "js-md5",
"version": "0.1.3",
"main": ["build/md5.min.js"],
"ignore": [
"samples",
"tests"
]
}
15 changes: 10 additions & 5 deletions build/md5.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"name": "js-md5",
"version": "0.1.2",
"version": "0.1.3",
"description": "A simple MD5 hash function for JavaScript supports UTF-8 encoding.",
"main": "src/md5.js",
"devDependencies": {
"expect.js": "~0.3.1",
"jscoverage": "~0.5.9"
},
"scripts": {
"test": "node tests/node-test.js"
"test": "mocha tests/node-test.js -r jscoverage",
"coveralls": "mocha tests/node-test.js -R mocha-lcov-reporter -r jscoverage | coveralls"
},
"repository": {
"type": "git",
Expand Down
Loading

0 comments on commit b31e43e

Please sign in to comment.