Password Hashing and Verification #13077
DavesCodeMusings
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
Thanks Daves there is also pyJWT which can do the job and is very improve .. It can work with simple secret_key with the algo your want (sha256 or +). There is example of jwt in Microdot web server to control web user access. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Password Hashing and Verification
I've created a MicroPython class to handle password hashing and verification for another project and I thought I'd share if anyone else is interested. I welcome any feedback to improve it.
I'll start by saying I'm not a cryptography expert, but I think what I came up with is usable and relatively secure on MycroPython-based systems.
I'm using Unix-style salted hashing as a template. My understanding of it is this:
Unix uses crypt and SHA-512. MicroPython has neither of these, so I'm using cryptolib's AES256 and hashlib's SHA256. Here's a high-level view of the steps:
The format is $type$salt$hashvalue, where $ separates the fields. For type, I made up a value of '5a', because in Linux and BSD '5' represents SHA-256 crypt. There is no designation for SHA-256 AES256, so I took the liberty of appending an 'a' similar to the way '2a' is used to indicate blowfish on some Linux systems.
I'm hoping this will provide a way to protect password data in flash storage. It's not as secure as a Unix system, but it's much better than cleartext. Thoughts from the cryptographically inclined are welcome.
Here's the class along with a sample you can run:
For a more robust example, see FTPdLite where this is used to store user credentials.
Beta Was this translation helpful? Give feedback.
All reactions