obj-encrypt is an encryption library based on the AES-256 algorithm. It uses Python objects as the basic unit, which can convert objects into binary ciphertext and support decryption. Objects encrypted with obj-encrypt support TCP communication, database storage, and more.
Project description
obj_encrypt
obj-encrypt is an encryption library based on the AES-256 algorithm. It uses Python objects as the basic unit, which can convert objects into binary ciphertext and support decryption. Objects encrypted with obj-encrypt support TCP communication, database storage, and more.
Installation
Recommended Environment: Python 3+
- Enter the command window, create a virtual environment, and enter the following commands in turn
Linux and macOS:
python3 -m venv venv # Create a virtual environment.
. venv/bin/activate # Activate the virtual environment.
Windows:
python -m venv venv # Create a virtual environment.
venv\Scripts\activate # Activate the virtual environment.
- Install obj-encrypt, enter in turn
pip install --upgrade pip
pip install obj-encrypt
Use
from obj_encrypt import Secret
def main():
secret = Secret(key='0123456789') # Initialize the secret instance, the key cannot exceed 32 strings.
# Build the data dictionary.
data = {
'author': 'Cyberbolt',
'personal_website': 'https://www.cyberlight.xyz/',
'time': '2021-02-10'
}
ciphertext = secret.encrypt(data) # Convert the object to binary ciphertext and get the ciphertext.
print(ciphertext, ' ', type(ciphertext))
data = secret.decrypt(ciphertext) # Decrypt ciphertext as object.
print(data)
if __name__ == '__main__':
main()
Output
b'U2FsdGVkX1/WxuK0iagq5jEbJsiIGvuNZieWehVYj7i+M66y06I1WcD7gBpPKniDhIkmSuVepFdMEisT8/+HqrWHHNwoY+waDERTes+7dGHvMBc4FcuTFjMzVoQZUE0SqFMi/ORhKcpCGgSUZo/gdNBPh0nNsRZ5ZQrKbt47aw6tSOEEXHwXEr20uHjqT7wx1uvsXnGbx1l91BNhEYrAIxhaJX0YTfGOgqVgCMc9k4xxSNEoB9v19873rryT5TnTXijNeA+FRtZKN5Mt9WUFMuBYCK5xWhXKv0BJOn8iGmw=' <class 'bytes'>
{'author': 'Cyberbolt', 'personal_website': 'https://www.cyberlight.xyz/', 'time': '2021-02-10'}
In addition to Python dictionaries, you can encrypt your own objects, and the encrypted binary can be stored in a database or used for TCP communication.
If this module was helpful to you, I hope to receive your GitHub Star! Thank you so much!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for obj_encrypt-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1272a9931d89b5af6039bfb8c304579e5c746c8597cc7a52ffa63b0d89bab74 |
|
MD5 | 6cc888affeefaa50733bec1227427c67 |
|
BLAKE2b-256 | e372cc83b9ced23b8b2903f67849fd98338b457849fff9c9daab906d5e33499e |