This repository has been archived by the owner on Dec 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
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
2 changed files
with
54 additions
and
4 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
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,51 @@ | ||
h1. sechash | ||
|
||
h4. Secure password hashing with salt and key stretching | ||
|
||
Author: James Brumond | ||
Version: 0.1.0 | ||
|
||
Copyright 2011 James Brumond | ||
Dual licensed under MIT and GPL | ||
|
||
h2. Install | ||
|
||
<pre><code>npm install sechash</code></pre> | ||
|
||
h2. Usage | ||
|
||
h3. Running a simple hash | ||
|
||
<pre><code>var sechash = require('sechash'); | ||
|
||
// This will do a simple md5 hash, the same as if you used the | ||
// built-in "crypto" module. | ||
var hash = sechash.simpleHash('md5', 'Your String');</code></pre> | ||
|
||
h3. Using the strong stuff | ||
|
||
<pre><code>var sechash = require('sechash'); | ||
|
||
// This will hash the string quite a bit more strongly. It adds | ||
// a salt parameter and an iterations parameter to make the hash | ||
// harder to break. | ||
var hash1 = sechash.strongHash('md5', 'Your String', 'Salt', 2500); | ||
|
||
// If no salt value is given, it will randomly generate salt for | ||
// you; similarly, if no iteration count is given, it will randomly | ||
// select a number between 1000 and 10000. | ||
var hash2 = sechash.strongHash('md5', 'Your String');</code></pre> | ||
|
||
h3. Testing a hash | ||
|
||
<pre><code>var sechash = require('sechash'); | ||
|
||
// First we generate a hash... | ||
var hash = sechash.strongHash('md5', 'Your String', 'Salt', 2500); | ||
|
||
// To test if a string matches a hash, we you the testHash method | ||
sechash.testHash('Your String', hash); // true | ||
sechash.testHash('Another String', hash); // false | ||
|
||
</code></pre> | ||
|