What is BCrypt?
The BCrypt Algorithm is used to hash and salt passwords in a secure way. BCrypt enables the creation of a password protection layer that can develop local hardware innovation in order to protect against long-term hazards or threats, such as attackers having the computational capacity to guess passwords twice as efficiently.
Install bcrypt using pip:
pip install bcrypt
Example: In this Program, we will be hashing the password using bcrypt.
Here we are using “GeekPassword” as an input to be converted to a hash.
Python
import bcrypt # Declaring our password password = b 'GeekPassword' # Adding the salt to password salt = bcrypt.gensalt() # Hashing the password hashed = bcrypt.hashpw(password, salt) # printing the salt print ( "Salt :" ) print (salt) # printing the hashed print ( "Hashed" ) print (hashed) |
Output:
How To Hash Passwords In Python
In this article, we are going to know how to hash passwords in python.
A strong password provides safety. Plain text passwords are extremely insecure, so we need to strengthen the passwords by hashing the password. Hashing passwords is a cheap and secure method that keeps the passwords safe from malicious activity. Password hashing generates a unique password for every text, even if the plaintext password is the same.