Last active
April 19, 2018 22:53
-
-
Save andrewfinnell/501af27a1321d520b76104e5c9fa39f3 to your computer and use it in GitHub Desktop.
Demonstration of Buffer and Secure Password generating different results even when the input is the same.
This file contains hidden or 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
| const sp = require('secure-password'); | |
| const pwd = sp(); | |
| var b1 = Buffer.from('Apples13'); | |
| var b2 = Buffer.from('Apples13'); | |
| var h1 = pwd.hashSync(b1); | |
| var h2 = pwd.hashSync(b2); | |
| var c1 = h1.toString('base64'); | |
| var c2 = h2.toString('base64'); | |
| var r1 = Buffer.from(c1, 'base64'); | |
| var r2 = Buffer.from(c2, 'base64'); | |
| console.log({ | |
| h1, | |
| h2, | |
| c1, | |
| c2, | |
| r1, | |
| r2, | |
| compare1: Buffer.compare(b1, b2) === 0 ? "compare1 Success" : "compare1 Fail", | |
| compare2: Buffer.compare(r1, r2) === 0 ? "compare1 Success" : "compare1 Fail", | |
| verify_b1_h1: pwd.verifySync(b1, h1), | |
| verify_b2_h1: pwd.verifySync(b2, h1), | |
| verify_b1_h2: pwd.verifySync(b1, h2), | |
| verify_b2_h2: pwd.verifySync(b2, h2), | |
| verify_r1_r2: pwd.verifySync(r1, r2) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.