Ask coding questions

← Back to all posts
crypto.scryptSync returning different results the second time
programmeruser

Somehow, the first time that crypto.scryptSync is run in the API, it generates a different hash then when run again, with the same password, salt, and length. What is causing this?

Voters
programmeruser
Comments
hotnewtop
CSharpIsGud

You set the salt to random bytes every time you set the password

programmeruser

@CSharpIsGud that's what I'm doing...

CSharpIsGud

@programmeruser So the hash will be different the second time since it got randomized didn't it? or do you mean the validate scrypt is generating a different hash than the scrypt to set the password?

programmeruser

@CSharpIsGud no, I meant that I store the salt in the db, and when I use the same salt it gives me a different result...

programmeruser

@CSharpIsGud I ended up using argon2 and it just worked