EncryptDecryptString is a Python class for easily encrypting and decrypting strings using the Fernet symmetric encryption algorithm from the cryptography library.
You can install EncryptDecryptString via pip:
pip install encryptdecryptstringfrom encryptdecryptstring import EncryptDecryptString
# Initialize EncryptDecryptString with a secret key
key = b'your_secret_key_here' # Replace 'your_secret_key_here' with an actual secret key
encryptor = EncryptDecryptString(key)
# Encrypt a message
encrypted_message = encryptor.encrypt("Hello, world!")
# Decrypt the encrypted message
decrypted_message = encryptor.decrypt(encrypted_message)
print(decrypted_message) # Output: Hello, world!
To generate a secret key, you can use the Fernet.generate_key() method provided by the cryptography library. Here's an example:
from cryptography.fernet import Fernet
# Generate a secret key
key = Fernet.generate_key()
print(key) # Output: b'...'Replace your_secret_key_here with the generated key.
Contributions are welcome! If you find a bug or have a suggestion for improvement, please open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
This README.md provides clearer instructions on how to install and use the package, including how to generate a secret key.