@@ -28,7 +28,8 @@ $ npm install --save credential
28
28
### .hash()
29
29
30
30
``` js
31
- var pw = require (' credential' ),
31
+ var credential = require (' credential' ),
32
+ pw = credential (),
32
33
newPassword = ' I have a really great password.' ;
33
34
34
35
pw .hash (newPassword, function (err , hash ) {
@@ -40,7 +41,8 @@ pw.hash(newPassword, function (err, hash) {
40
41
### .verify()
41
42
42
43
``` js
43
- var pw = require (' credential' ),
44
+ var credential = require (' credential' ),
45
+ pw = credential (),
44
46
storedHash = ' {"hash":"gNofnhlBl36AdRyktwATxKoqWKa6hsIEzwCmW/YXN//7PtiJwCRbepV9fUKu0L9TJELCKoDiBy6rGM8ov7lg2yLY","salt":"yyN3KUzlr4KrKWMM2K3d2Ddxf8OTq+vkKG+mtnmQVIibxSJz8drfzkYzqcH0EM+PVKR/1nClRr/CPDuJsq+FOcIw","keyLength":66,"hashMethod":"pbkdf2","iterations":181019}' ,
45
47
userInput = ' I have a really great password.' ;
46
48
@@ -54,7 +56,18 @@ pw.verify(storedHash, userInput, function (err, isValid) {
54
56
55
57
## API
56
58
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)
58
71
59
72
Takes a new password and creates a unique hash. Passes a JSON encoded object to the callback.
60
73
@@ -73,7 +86,7 @@ Takes a new password and creates a unique hash. Passes a JSON encoded object to
73
86
* @param {Number} hashObject.iterations
74
87
75
88
76
- ### .verify(hash, input, callback) callback(err, isValid)
89
+ ### pw .verify(hash, input, callback) callback(err, isValid)
77
90
78
91
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.
79
92
@@ -82,26 +95,14 @@ Takes a stored hash, password input from the user, and a callback, and determine
82
95
* @param {Function} callback(err, isValid)
83
96
84
97
85
- ### .expired(hash[ , days = 90] )
98
+ ### pw .expired(hash[ , days = 90] )
86
99
87
100
Takes a stored hash and a number of days, and determines if the hash is older than the specified days.
88
101
89
102
* @param {String} hash A stored password hash
90
103
* @param {Number} days Days before expiry
91
104
92
105
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
-
105
106
## CLI
106
107
107
108
[ See CLI docs] ( docs/cli.md )
0 commit comments