This project demonstrates how to encrypt and hash data securely using Python. It includes examples of symmetric encryption (AES), hashing with SHA-256, and secure password handling with bcrypt.
Key Features
- Encrypt text using AES encryption (from the
cryptography
library) - Hash data using SHA-256 and SHA-512
- Secure password storage using bcrypt
- Python script input/output for easy testing
Sample Code Snippets
SHA-256 Hashing
import hashlib
text = "SecureMessage123"
hashed = hashlib.sha256(text.encode()).hexdigest()
print("SHA-256 Hash:", hashed)
AES Encryption
from cryptography.fernet import Fernet
key = Fernet.generate_key()
cipher = Fernet(key)
message = b"Encrypt this text"
encrypted = cipher.encrypt(message)
decrypted = cipher.decrypt(encrypted)
print("Encrypted:", encrypted)
print("Decrypted:", decrypted)
Password Hashing with bcrypt
import bcrypt
password = b"SuperSecretPassword"
salt = bcrypt.gensalt()
hashed = bcrypt.hashpw(password, salt)
print("Hashed password:", hashed)