Giter Site home page Giter Site logo

Verifying password about scrypt-async-js HOT 6 CLOSED

lewispham avatar lewispham commented on August 26, 2024
Verifying password

from scrypt-async-js.

Comments (6)

evilaliv3 avatar evilaliv3 commented on August 26, 2024

@Tresdin:

  1. to verify a password hashed by scrypt-async you should recalculate the scrypt hash and see if it maches the one that you stored.
  2. yep aside from bugs in the implementation they should be compatible.

from scrypt-async-js.

lewispham avatar lewispham commented on August 26, 2024

@evilaliv3 I wonder if there would be any standard instruction or specification for password verification in scrypt. Because in bcrypt, this task is complicated. You can see this post for more details.

from scrypt-async-js.

dchest avatar dchest commented on August 26, 2024

@Tresdin there were attempts to make a universal text encoding for scrypt (params + salt + hash), but so far there are many different implementations. All you need is just to store this information:

{
   logN: ..., // or N
   r: ...,
   p: ..., // always 1 for scrypt-async-js
   salt: ..., // possibly base64 encoded
   hash: ...,  // possibly base64 encoded
}

To verify, read parameters and salt from storage, generate a new hash with the password you're trying to verify and compare to the stored one.

from scrypt-async-js.

lewispham avatar lewispham commented on August 26, 2024

@dchest Since derived key length is a required parameter in scrypt-async, do I need to include it into hash string? And also, what is p parameter? Why is it so important? Or do you have any source that explains these params?

from scrypt-async-js.

dchest avatar dchest commented on August 26, 2024

Ah, true, if you ever want to change the hash length, save it. But I'd just fix it to 32 (if you don't need more derived keys for other purposes). P is parallelization parameter: it tells how many parallel instances to calculate in order to fill more CPU cores. It's fixed to 1 in scrypt-async-js for simplicity (and because apart from web workers JS doesn't parallelize).

The source is the original scrypt paper: https://www.tarsnap.com/scrypt/scrypt.pdf

from scrypt-async-js.

lewispham avatar lewispham commented on August 26, 2024

I used to be stuck with picking between scrypt and bcrypt for password hashing because of this issue. I think it's no longer a problem to me. Thank you so much @dchest .

from scrypt-async-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.