Skip to content

Commit 739858b

Browse files
Thomas Sileghemmastilver
Thomas Sileghem
authored andcommitted
doc: credential need to be instanciante before use
1 parent 3f28cf0 commit 739858b

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

README.md

+18-17
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ $ npm install --save credential
2828
### .hash()
2929

3030
```js
31-
var pw = require('credential'),
31+
var credential = require('credential'),
32+
pw = credential(),
3233
newPassword = 'I have a really great password.';
3334

3435
pw.hash(newPassword, function (err, hash) {
@@ -40,7 +41,8 @@ pw.hash(newPassword, function (err, hash) {
4041
### .verify()
4142

4243
```js
43-
var pw = require('credential'),
44+
var credential = require('credential'),
45+
pw = credential(),
4446
storedHash = '{"hash":"gNofnhlBl36AdRyktwATxKoqWKa6hsIEzwCmW/YXN//7PtiJwCRbepV9fUKu0L9TJELCKoDiBy6rGM8ov7lg2yLY","salt":"yyN3KUzlr4KrKWMM2K3d2Ddxf8OTq+vkKG+mtnmQVIibxSJz8drfzkYzqcH0EM+PVKR/1nClRr/CPDuJsq+FOcIw","keyLength":66,"hashMethod":"pbkdf2","iterations":181019}',
4547
userInput = 'I have a really great password.';
4648

@@ -54,7 +56,18 @@ pw.verify(storedHash, userInput, function (err, isValid) {
5456

5557
## API
5658

57-
### .hash(password, callback) callback(err, hashJSON)
59+
### var pw = credential([options])
60+
61+
Return an instance of credential
62+
63+
Warning: Decreasing `keyLength` or `work` can make your password database less secure.
64+
65+
* @param {Object} options Options object.
66+
* @param {Number} options.keyLength
67+
* @param {Number} options.work
68+
* @return {Object} credential object
69+
70+
### pw.hash(password, callback) callback(err, hashJSON)
5871

5972
Takes a new password and creates a unique hash. Passes a JSON encoded object to the callback.
6073

@@ -73,7 +86,7 @@ Takes a new password and creates a unique hash. Passes a JSON encoded object to
7386
* @param {Number} hashObject.iterations
7487

7588

76-
### .verify(hash, input, callback) callback(err, isValid)
89+
### pw.verify(hash, input, callback) callback(err, isValid)
7790

7891
Takes a stored hash, password input from the user, and a callback, and determines whether or not the user's input matches the stored password.
7992

@@ -82,26 +95,14 @@ Takes a stored hash, password input from the user, and a callback, and determine
8295
* @param {Function} callback(err, isValid)
8396

8497

85-
### .expired(hash[, days = 90])
98+
### pw.expired(hash[, days = 90])
8699

87100
Takes a stored hash and a number of days, and determines if the hash is older than the specified days.
88101

89102
* @param {String} hash A stored password hash
90103
* @param {Number} days Days before expiry
91104

92105

93-
### .configure(options)
94-
95-
Alter settings.
96-
97-
Warning: Decreasing `keyLength` or `work` can make your password database less secure.
98-
99-
* @param {Object} options Options object.
100-
* @param {Number} options.keyLength
101-
* @param {Number} options.work
102-
* @return {Object} credential object
103-
104-
105106
## CLI
106107

107108
[See CLI docs](docs/cli.md)

0 commit comments

Comments
 (0)