Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5f0b13b
Showing
8 changed files
with
32,080 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Contributing | ||
============ | ||
|
||
1. Fork it | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Add some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create new Pull Request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Copyright (c) 2015 Thomas Cort <linuxgeek@gmail.com> | ||
|
||
Permission to use, copy, modify, and distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# passwd-strength | ||
|
||
Simple password strength calculator. It computes the number of bits of entropy of a given password | ||
and also checks the password against a list of over 30,000 common passwords. | ||
|
||
## Installation | ||
|
||
npm install --save passwd-strength | ||
|
||
## API | ||
|
||
### passwdStrength(passwd) | ||
|
||
Parameters: | ||
|
||
* `passwd` - the password to test. | ||
|
||
Returns: | ||
|
||
* The number of bits of entropy (floating point number). Higher is better. 0 is returned when a common passwords such as `abc123`, `password`, etc is encountered. | ||
|
||
## Example | ||
|
||
``` | ||
"use strict"; | ||
var passwdStrength = require('passwd-strength'); | ||
app.post('/register', function (req, res, next) { | ||
if (passwdStrength(req.body.passwd) < 29) { | ||
next(new Error('Password not strong enough. Add entropy by increasing the password length and including upper case letters, lower case letters, digits, and punctuation.')); | ||
return; | ||
} | ||
// ... | ||
}); | ||
``` | ||
|
||
## Tips | ||
|
||
[RFC4086](https://tools.ietf.org/html/rfc4086) has a section on [Password Generation](https://tools.ietf.org/html/rfc4086#page-35) | ||
that explains how to determine how much entropy you need. | ||
|
||
## License | ||
|
||
``` | ||
Copyright (c) 2015 Thomas Cort <linuxgeek@gmail.com> | ||
Permission to use, copy, modify, and distribute this software for any | ||
purpose with or without fee is hereby granted, provided that the above | ||
copyright notice and this permission notice appear in all copies. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
"use strict"; | ||
|
||
var fs = require('fs'); | ||
var path = require('path'); | ||
|
||
Math.log2 = Math.log2 || function(x) { // for node v0.10 | ||
return Math.log(x) / Math.LN2; | ||
}; | ||
|
||
module.exports = function passwdStrength(passwd) { | ||
|
||
if (fs.readFileSync(path.join(__dirname, 'passwords.txt')).toString().split("\n").indexOf(passwd.toLowerCase()) !== -1) { | ||
return 0; | ||
} | ||
|
||
return passwd.length * Math.log2([ | ||
{ r: /[0-9]/, size: 10 }, | ||
{ r: /[A-Z]/, size: 26 }, | ||
{ r: /[a-z]/, size: 26 }, | ||
{ r: /[^0-9A-Za-z]/, size: 33 } | ||
].reduce(function (sum, clazz) { | ||
if (clazz.r.test(passwd)) { | ||
sum += clazz.size; | ||
} | ||
return sum; | ||
}, 0)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
{ | ||
"name": "passwd-strength", | ||
"version": "0.0.0", | ||
"description": "computes password strength and checks against a list of common passwords", | ||
"main": "index.js", | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"scripts": { | ||
"pretest": "jshint index.js", | ||
"test": "mocha -R spec" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/tcort/passwd-strength.git" | ||
}, | ||
"keywords": [ | ||
"password", | ||
"strength", | ||
"checker", | ||
"entropy" | ||
], | ||
"author": "Thomas Cort <linuxgeek@gmail.com>", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/tcort/passwd-strength/issues" | ||
}, | ||
"homepage": "https://github.com/tcort/passwd-strength#readme", | ||
"devDependencies": { | ||
"expect.js": "^0.3.1", | ||
"jshint": "^2.8.0", | ||
"mocha": "^2.3.3" | ||
}, | ||
"jshintConfig": { | ||
"bitwise": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"forin": true, | ||
"freeze": true, | ||
"globalstrict": true, | ||
"immed": true, | ||
"indent": 4, | ||
"moz": true, | ||
"newcap": true, | ||
"noarg": true, | ||
"node": true, | ||
"noempty": true, | ||
"nonew": true, | ||
"trailing": true, | ||
"undef": true, | ||
"smarttabs": true, | ||
"strict": true, | ||
"validthis": true, | ||
"globals": { | ||
"describe": false, | ||
"it": false, | ||
"before": false, | ||
"beforeEach": false, | ||
"after": false, | ||
"afterEach": false | ||
} | ||
} | ||
} |
Oops, something went wrong.