-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
14 changed files
with
273 additions
and
243 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,9 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
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,2 @@ | ||
node_modules | ||
coverage |
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,59 @@ | ||
{ | ||
"env": { | ||
"es6": true, | ||
"node": true, | ||
"browser": true | ||
}, | ||
"globals": { | ||
"log": false | ||
}, | ||
"rules": { | ||
"brace-style": [2, "stroustrup", {"allowSingleLine": true}], | ||
"camelcase": [2, {"properties": "never"}], | ||
"comma-dangle": [2], | ||
"comma-style": [2, "last"], | ||
"computed-property-spacing": [2, "never"], | ||
"curly": [2], | ||
"eol-last": [2], | ||
"eqeqeq": [2, "smart"], | ||
"indent": [2, 2, {"SwitchCase": 1}], | ||
"key-spacing": [2], | ||
"keyword-spacing": [2], | ||
"linebreak-style": [2, "unix"], | ||
"no-extra-parens": [2], | ||
"no-multiple-empty-lines": [2], | ||
"no-return-assign": [0], | ||
"no-sequences": [2], | ||
"no-shadow": [2], | ||
"no-spaced-func": [2], | ||
"no-trailing-spaces": [2], | ||
"no-undef-init": [2], | ||
"no-undefined": [2], | ||
"no-unneeded-ternary": [2], | ||
"no-use-before-define": [2, {"functions": false}], | ||
"no-useless-concat": [2], | ||
"no-var": [2], | ||
"no-whitespace-before-property": [2], | ||
"object-shorthand": [2], | ||
"object-curly-spacing": [2, "never"], | ||
"operator-assignment": [2, "always"], | ||
"operator-linebreak": [2, "after", {"overrides": {"?": "before", ":": "before"}}], | ||
"one-var": [2, "never"], | ||
"prefer-arrow-callback": [2], | ||
"prefer-const": [2], | ||
"prefer-template": [2], | ||
"quote-props": [2, "as-needed"], | ||
"quotes": [2, "single"], | ||
"radix": [2], | ||
"semi": [2, "never"], | ||
"semi-spacing": [2], | ||
"space-before-blocks": [2], | ||
"space-before-function-paren": [2], | ||
"space-in-parens": [2, "never"], | ||
"space-infix-ops": [2], | ||
"space-unary-ops": [2], | ||
"strict": [2, "global"], | ||
"yoda": [2, "never"] | ||
}, | ||
"extends": "eslint:recommended" | ||
} |
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,5 @@ | ||
node_modules | ||
coverage | ||
npm-debug.log* | ||
.vscode | ||
.idea |
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 @@ | ||
language: node_js | ||
sudo: false | ||
|
||
node_js: | ||
- "6" | ||
|
||
after_script: | ||
npm run coveralls |
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 |
---|---|---|
@@ -1,17 +1,20 @@ | ||
The MIT License (MIT) | ||
Copyright (c) Tyler Waters <tyler.waters@gmail.com> | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
Copyright (c) 2015 Tyler Waters | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 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 |
---|---|---|
@@ -1,47 +1,80 @@ | ||
# native-password-hash | ||
# Hashifier | ||
|
||
Wrapper to nodejs' native crypto library, for hashing passwords. | ||
This is a lightweight alternative to using brypt; no compilation steps. | ||
[![npm version][npm-badge]][npm-url] | ||
[![Build Status][travis-badge]][travis-url] | ||
[![Coverage Status][coveralls-badge]][coveralls-url] | ||
[![Dependency Status][david-badge]][david-url] | ||
|
||
Light-weight wrapper to nodejs crypto library for hashing passwords using pbkdf2 | ||
|
||
## Requirements | ||
|
||
node 6. | ||
|
||
## Install | ||
|
||
npm install native-password-hash | ||
``` | ||
npm install hashifier | ||
``` | ||
|
||
## Usage | ||
## API | ||
|
||
Each function returns a promise that resolves as specified. | ||
|
||
const pass = require('password-hash') | ||
const hash = pass.hash('my password') // store this somewhere | ||
pass.compare('my password', hash) // true | ||
pass.compare('not my password', hash) // false | ||
Any errors encountered by the crypto module will reject the promise. | ||
|
||
You can pass an options object as the last parameter to `hash`. | ||
It accepts the following parameters: | ||
_hash(plainText, options?)_ | ||
- hash a given password | ||
- resolves to an object, {hash, salt} | ||
- see options below | ||
|
||
| value | default | description | | ||
|------------|---------|--------------------------------------| | ||
| algorithm | sha512 | algorithm to use for generating hash | | ||
| iterations | 4096 | number of hasing iterations to use | | ||
| saltLength | 36 | length of the salt. | | ||
_compare(plainText, hash, salt, options?)_ | ||
- compare a previously hashed password | ||
- resolves to a boolean | ||
- see options below | ||
|
||
The returned string from hash will looks like the following: | ||
### options | ||
|
||
{algorithm}${salt}${iterations}${hash} | ||
- _iterations_ - number of iterations to hash (default 100,000) | ||
- _algorithm_ - algorithm to use for hashing (default sha512) | ||
- _encoding_ - output encoding to use (default hex) | ||
- _saltLength_ - number of bytes to use for the salt (default 128) | ||
- _keyLength_ - length of the key (default 128) | ||
|
||
## Benchmark | ||
## Usage | ||
|
||
```js | ||
const hashifier = require('hashifier') | ||
|
||
// options are optional, following is default | ||
const options = { | ||
iterations: 100000 | ||
algorithm: 'sha512' | ||
encoding: 'hex' | ||
saltLength: = 128 | ||
keyLength: 128 | ||
} | ||
|
||
You can use the benchmark utility to find out how long a given hashing operation takes. | ||
hashifier.hash('my password', options) // {salt: string, hash: string} | ||
.then(result => { | ||
|
||
$ node benchmark.js --help | ||
native-password-hash benchmarking utility; determines how long it takes to hash | ||
use this to get an idea of what to pass to {options}, given your requirements. | ||
usage: node benchmark.js [options] [time] | ||
time is the number of milliseconds you want to wait. | ||
options: | ||
--help show this help. | ||
--saltLength length of the salt in bytes | ||
--algorithm algorithm to use for hashing. | ||
--password password to hash [default=test] | ||
hashifier.compare('my password', result.hash, result.salt, options) | ||
.then(result => assert.ok(result)) | ||
|
||
hashifier.compare('not my password', result.hash, result.salt, options) | ||
.then(result => result.notOk(result)) | ||
}) | ||
``` | ||
|
||
## License | ||
|
||
MIT. | ||
MIT. | ||
|
||
[npm-badge]: https://badge.fury.io/js/hashifier.svg | ||
[npm-url]: https://badge.fury.io/js/hashifier | ||
[travis-badge]: https://travis-ci.org/tswaters/hashifier.svg?branch=master | ||
[travis-url]: https://travis-ci.org/tswaters/hashifier | ||
[coveralls-badge]: https://coveralls.io/repos/github/tswaters/hashifier/badge.svg?branch=master | ||
[coveralls-url]: https://coveralls.io/github/tswaters/hashifier?branch=master | ||
[david-badge]: https://david-dm.org/tswaters/hashifier.svg | ||
[david-url]: https://david-dm.org/tswaters/hashifier |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.