0

I want to check a user input() against a password, but I do not want to store the actual password anywhere. I am thinking to encrypt the input and the password in the same way, then check those against each other. However, I am unable to find anything on one-way encryption in Python.

1). Is this the best solution? (If not, what is the best solution?)

2). How would I implement this?

I tried to use the built-in hash() function, but every time I run the program, the same value generates a different hash.

Nathan Dai
  • 392
  • 2
  • 11
  • 1
    What you are looking for (one way encryption) is called hashing. Python's `hash()` function is not a cryptographic hash, it's merely for quickly finding elements in a set or a similar data structure. Passwords are usually hashed using `sha1` or better algorithms. You should also research the concept of a "salt" to alleviate attacks that use "rainbow tables". That's a lot of reading. – Selcuk Sep 27 '21 at 06:28
  • 1
    Search for Scrypt, Bcrypt or Argon2 as they provide the requested functionality. – Michael Fehr Sep 27 '21 at 06:56
  • @MichaelFehr Thank you! I was able to get it to work using Scrypt. – Nathan Dai Sep 28 '21 at 17:32

0 Answers0