Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash and Verify taking too much time #89

Open
kanaxz opened this issue Dec 6, 2023 · 1 comment
Open

Hash and Verify taking too much time #89

kanaxz opened this issue Dec 6, 2023 · 1 comment

Comments

@kanaxz
Copy link

kanaxz commented Dec 6, 2023

Hi there ! I hope I'm not putting this message at the wrong place.

I'm working in a team and our project is using your package "credential": "^2.0.0"
I was investigating our login feature taking too much time and it appears that it is coming from the verify function (from 3s to 5s)
I've written this little test to confirm that:

const credential = require('credential')()

const start = async () => {
  let start = new Date()
  const pwd = 'myLittlePassword!#56'
  const hash = await credential.hash(pwd)
  console.log(hash, new Date() - start)
  start = new Date()
  const isValid = await credential.verify(hash, pwd)
  console.log(isValid, new Date() - start)
}

start()

And both the hash and verify functions take around 5 seconds each.
Is it normal to take that long ?
Thanks !

@tjconcept
Copy link
Collaborator

Yes, that's expected.

You can adjust the work required (thus the time it takes) with the work parameter.

Reconsider if you need passwords (in your database) at all, or could use a safer design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants