Save passwords with Python?
Good evening, I have a question regarding Python and password storage. I sometimes program small systems on my phone using Python with the Pyto app. The problem is that I want to code a password system, but I have no idea how to do it. Can anyone help me?
Best regards
Passwords may not be stored in plain text. They are usually stored as hash values. A hash value is an encrypted form of the password that can no longer be recalculated. Hashening the password with SHA256 works in Python as follows:
The hash value is stored in the variable hash, which can then be stored in e.g. a file. It is important, however, that a modification of this file is excluded or is automatically recognized by program. This could be solved by encrypting the content to which access is to be accessed with the password (e.g. with Fernet) and decrypting it when registering.
If you want to check if the entered password is correct, you will proceed as follows:
The principle behind this is the following: You cannot calculate the hash of the correct password, but you can calculate the hash of the input password. Thus you have the hash value of the correct password and that of the input password. If both agree, the password was correct.
Thank you. You’re the only person that could help me. Thanks (╹◡╹)
I personally lack some salt in this solution:(