A Python package for asymmetric encryption using RSA.
pip install rsa-crypto-python
from rsa_crypto_python.rsa_crypto_python import RSAEncryption
# Create an instance of the RSAEncryption class
rsa = RSAEncryption()
# rsa = RSAEncryption(env_file_path=None)
# crypt private_to_public
original_text = 'Hello, this is a secret message!'
encrypted_text = rsa.encrypt_with_private_key(original_text)
print('Encrypted Text:', encrypted_text)
decrypted_text = rsa.decrypt_with_public_key(encrypted_text)
print('Decrypted Text:', decrypted_text)
# crypt public_to_private
original_text = 'Hello, this is a secret message!'
encrypted_text = rsa.encrypt_with_public_key(original_text)
print('Encrypted Text:', encrypted_text)
decrypted_text = rsa.decrypt_with_private_key(encrypted_text)
print('Decrypted Text:', decrypted_text)
Set your public and private key paths in a .env file:
PUBLIC_KEY_PATH=/path/to/your/keys/public_key.pem
PRIVATE_KEY_PATH=/path/to/your/keys/private_key.pem
Generate Private Key
openssl genpkey -algorithm RSA -out keys/private_key.pem
Generate Public Key
openssl rsa -pubout -in keys/private_key.pem -out keys/public_key.pem
- Fork the repository
- Create a new branch (
git checkout -b feature/awesome-feature
) - Commit your changes (
git commit -am 'Add awesome feature'
) - Push to the branch (
git push origin feature/awesome-feature
) - Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to the cryptography library for providing the tools for secure communication.
Ukweh Everest
For any inquiries, please contact [[email protected]].