Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
ranisalt committed Dec 20, 2015
1 parent da43d83 commit e67fbba
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,47 @@ Bindings to the reference [Argon2](https://github.com/P-H-C/phc-winner-argon2).
implementation.

### Usage
Currently, only the encrypt and verify methods are implemented for Argon2i,
asynchronously.
Currently, only the encrypt and verify methods are implemented for Argon2i.

To hash a password:
```js
var argon2 = require('argon2');

argon2.encrypt('password', 'somesalt', function(err, hash) {
argon2.encrypt('password', 'somesalt', function (err, hash) {
if (err) // encryption failure
throw err;

doSomethingWith(hash);
});

// OR

try {
var hash = argon2.encryptSync('password', 'somesalt');
} catch (err) {
console.log(err);
}
```
Resultant hashes will be 90 characters long.

To verify a password:
```js
var argon2 = require('argon2');

argon2.verify('<big long hash>', 'password', function(err) {
argon2.verify('<big long hash>', 'password', function (err) {
if (err) // password did not match
throw err;

authenticate();
});

// OR

if (argon2.verifySync('<big long hash>', 'password')) {
authenticate();
} else {
fail();
}
```
First parameter must have been generated by an Argon2 encoded hashing method,
not raw.
Expand Down

0 comments on commit e67fbba

Please sign in to comment.