r/pythonhelp • • May 25 '22

Best practice for storing passwords (special case)

Hi there!
I'm writing a Python script that interfaces with an API that users can login to (that doesn't have API keys or anything like that). Really, it just requires a username, password, and URL.

For testing, I have been using a web page to make POST requests with this info back to my script (a Flask application). But if I'm going to make this public, I don't think users would be enamored with the idea of this info being sent in plain text over the internet (even HTTPS I know) and then also stored in plain text on my server that doesn't have enterprise-grade security.

How would you recommend I go about this? If I just wanted to use a password for authentication, I could just hash it and store that. But because I need the actual password to connect to this other API, I can't really do that because you can't decrypt SHA-256.

Any suggested methods/libraries/hashing algorithms that might do this job better? Ideally something that could also be implemented in JS on my web interface.

Thanks!

4 Upvotes

1 comment sorted by

2

u/Obed2621 Jun 15 '22

Did you look at the secure standard library’s module? I read all these doc but never used i have not really idea mate