I'm using some software that stores it's internal user database in a JSON file (users.json) where each user has a field called password where the values look like this:
pbkdf2:10000:f30dd5755d4d172d:e7b2fdda936b4ad5335c3b76c8f3568b0e3b14ce1d9b8ca1e32b7627545d0a3811aa3407a814731b1ee1c86e108c66c1616b1ea2570f7ecf8d04d4f465c33947
I want to modify this users.json programatically from python to reset a user password, without having to go through this application UI.
How can I generate a pbkdf2:xxxxxx string for a new password?
The
follows the format
to generate a new
pbkdf2:xxxyou can use hashlib.pbkdf2_hmac which is builtin since Python 3.4.For example the
pbkdf2:10000:f30dd5755d4d172d:e7b2fdda936b4ad5335c3b76c8f3568b0e3b14ce1d9b8ca1e32b7627545d0a3811aa3407a814731b1ee1c86e108c66c1616b1ea2570f7ecf8d04d4f465c33947seems to be the hash of the passwordadminusingpbkdf2_hmac('sha1',...)You can generate the hash for password
adminand saltf30dd5755d4d172dover10000iterations like this:Or in general for a completely new password (with a new random salt):