alexedwards / argon2id

Argon2id password hashing and verification for Go
MIT License
452 stars 44 forks source link

add CheckHash and export DecodeHash #10

Closed natefinch closed 3 years ago

natefinch commented 3 years ago

This change exports the function DecodeHash and adds a new function CheckHash, which returns the parameters used to create the given hash. This is useful for real-world use of argon2id hashing, where you should periodically upgrade the hashing parameters to keep up with increasing processor speed. In order to do that, you need to get the parameters a hash was saved with, to compare against your current gold standard.

natefinch commented 3 years ago

Hi! We're migrating our user system at Mattel from bcrypt to argon2id, and I came across this repo, which wraps everything up nicely in a way I didn't want to have to write manually. However, there was one piece of missing functionality - which was returning the params that a password was hashed with, so we can know if we need to re-hash the password with updated params. I don't technically need DecodeHash exported right now, but it seems like the kind of utility function that could be useful if extracting data from a database directly or something similar.

natefinch commented 3 years ago

Alternatively, I'm happy to fork this and put it up at github.com/Mattel if you don't want to be hassled with maintaining it.

alexedwards commented 3 years ago

No, it's all OK, Christmas is just a busy time :smiley:

Thanks for the PR. It all looks good and I've merged it now :+1:

natefinch commented 3 years ago

Awesome. Merry Christmas! :)

natefinch commented 3 years ago

And believe me, I understand being a busy maintainer :)