Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
- simplify test running instructions
- syntax highlight for examples
- windows version notes
  • Loading branch information
defunctzombie committed Aug 3, 2012
1 parent 2c34bc7 commit 7bed481
Showing 1 changed file with 45 additions and 29 deletions.
74 changes: 45 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Version Compatability
</tr>
</table>

Windows users should make sure to have at least node 0.8.5 installed and version >= 0.7.1 of this module.


Security Issues/Concerns
=============
Expand Down Expand Up @@ -51,10 +53,12 @@ From Source

Assuming you've already built node, you can compile the module with `node-gyp`:

git clone git://github.com/ncb000gt/node.bcrypt.js.git
cd node.bcrypt.js
node-gyp configure
node-gyp build
```
git clone git://github.com/ncb000gt/node.bcrypt.js.git
cd node.bcrypt.js
node-gyp configure
node-gyp build
```

Note: if you do not have node-gyp installed, install it using: `npm install -g node-gyp`

Expand All @@ -63,47 +67,59 @@ Usage - Sync

To hash a password:

var bcrypt = require('bcrypt');
var salt = bcrypt.genSaltSync(10);
var hash = bcrypt.hashSync("B4c0/\/", salt);
// Store hash in your password DB.
```javascript
var bcrypt = require('bcrypt');
var salt = bcrypt.genSaltSync(10);
var hash = bcrypt.hashSync("B4c0/\/", salt);
// Store hash in your password DB.
```

To check a password:

// Load hash from your password DB.
bcrypt.compareSync("B4c0/\/", hash); // true
bcrypt.compareSync("not_bacon", hash); // false
```javascript
// Load hash from your password DB.
bcrypt.compareSync("B4c0/\/", hash); // true
bcrypt.compareSync("not_bacon", hash); // false
```

Auto-gen a salt and hash:

var hash = bcrypt.hashSync('bacon', 8)
```javascript
var hash = bcrypt.hashSync('bacon', 8);
```

Usage - Async
============

To hash a password:

var bcrypt = require('bcrypt');
bcrypt.genSalt(10, function(err, salt) {
bcrypt.hash("B4c0/\/", salt, function(err, hash) {
// Store hash in your password DB.
});
```javascript
var bcrypt = require('bcrypt');
bcrypt.genSalt(10, function(err, salt) {
bcrypt.hash("B4c0/\/", salt, function(err, hash) {
// Store hash in your password DB.
});
});
```

To check a password:

// Load hash from your password DB.
bcrypt.compare("B4c0/\/", hash, function(err, res) {
// res == true
});
bcrypt.compare("not_bacon", hash, function(err, res) {
// res = false
});
```javascript
// Load hash from your password DB.
bcrypt.compare("B4c0/\/", hash, function(err, res) {
// res == true
});
bcrypt.compare("not_bacon", hash, function(err, res) {
// res = false
});
```

Auto-gen a salt and hash:

bcrypt.hash('bacon', 8, function(err, hash) {
});
```javascript
bcrypt.hash('bacon', 8, function(err, hash) {
});
```

API
============
Expand Down Expand Up @@ -149,10 +165,10 @@ The characters that comprise the resultant hash are `./ABCDEFGHIJKLMNOPQRSTUVWXY
Testing
============

I am using nodeunit. I like the way you write tests with it and I like the default output. As such you'll need it to run the tests. I suspect my tests would run on an older version, but these were written and worked against 0.5.1
If you create a pull request, tests better pass :)

npm install nodeunit@0.5.1
nodeunit test/
npm install
npm test

Credits
============
Expand Down

0 comments on commit 7bed481

Please sign in to comment.