barrysteyn / node-scrypt

Scrypt for Node
370 stars 88 forks source link

verifyKdfSync giving native error #161

Open frkn-aydn opened 7 years ago

frkn-aydn commented 7 years ago

I am using this,

Something wrong my scrypt module. I am using this,

const scrypt = require("scrypt")

> const parola = scrypt.kdfSync("123123123", scrypt.paramsSync(0.1)).toString('base64');
// returning this : 'c2NyeXB0AA0AAAAIAAAAAYp0fM3NLyhdqS0CUXjFLZnOpnkZq4lgqJMvctHS865sM9K14pRbnPBzSDREnzjnLbzTln8NnfxFhD6fNufZzfdBu1y5OMR3xozm6PFvpiFM'

> scrypt.verifyKdfSync(new Buffer(parola), new Buffer("123123123"))
Error
    at Error (native)    at Object.verifyKdfSync (/home/vircon/Desktop/HousePecker/node_modules/scrypt/index.js:331:25)
    at repl:1:8
    at sigintHandlersWrap (vm.js:22:35)
    at sigintHandlersWrap (vm.js:73:12)
    at ContextifyScript.Script.runInThisContext (vm.js:21:12)
    at REPLServer.defaultEval (repl.js:340:29)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.<anonymous> (repl.js:539:10)

I am using ubuntu 16.04 nodejs version : v6.11.4 scrypt version : 6.0.3

frkn-aydn commented 6 years ago

Ok i fixed <3

To fix it use new Buffer( / Password / , 'base64') and would look like this:

scrypt.verifyKdf(new Buffer(password, 'base64'), password)

if anyone get this error, just write "base64" argument as a secont argument in buffer function. Thats all :)

barrysteyn commented 6 years ago

Hi - I am getting much more time to devote to this project again. Sorry I have been so quiet. Lets get this merged in ASAP. I will look into it tomorrow morning...