obj_encrypt
obj-encrypt is an encryption library based on the 'AES-256-GCM' algorithm. It uses Python objects as the basic unit and it 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():
# Initialize the secret instance, the key is an AES-256 key, and the maximum size cannot exceed 32 strings.
secret = Secret(key='0123456789')
# build the data dictionary
data = {
'author': 'Cyberbolt',
'personal_website': 'https://www.cyberlight.xyz/',
'time': '2022-02-10'
}
ciphertext = secret.encrypt(data) # Convert the object to binary ciphertext and get the ciphertext.
print(ciphertext, ' ', type(ciphertext))
plaintext = secret.decrypt(ciphertext) # Decrypt ciphertext as object.
print(plaintext)
if __name__ == '__main__':
main()
Output
b'U2FsdGVkX18IANYgINODlF8BjkxI3AaKJ/+10Iexgh65qyEKFY21HK5LSjiTuy37arjYAuIQQls+amqCdEdVdy0V1E6xECJXOFBb0kfIzQuxOimOaFFVvtq4IntjJNdCHLiTwuExVfwAW7CjqaD554B71IoT0o9xqrFch3N0vtq+UP0uXyMmMCsvu8zY7vrCuw9qM+kOW2VWsC2c2ePDnofvakchgDW9bGF8fTC3prE+TPksoJ4l6ERCjjRid54gP6+HmzB+TwOVSGaj+4VIdm1g7qv591tBU1U6Lxm83Hk=' <class 'bytes'>
{'author': 'Cyberbolt', 'personal_website': 'https://www.cyberlight.xyz/', 'time': '2022-02-10'}
You can encrypt your own objects in addition to Python dictionaries, 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!
Metadata
Release files for obj-encrypt 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| obj-encrypt-0.7.0.tar.gz | 3.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| obj_encrypt-0.7.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.1 kB
Release files / obj-encrypt-0.7.0.tar.gz
| Download URL | obj-encrypt-0.7.0.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
227932e50b27c50f084d02bfa9802ef079da3114cf4eea8227e428df750faa50
|
|
BLAKE2b-256 checksum How to use checksums |
1c7c458432f0b4364c1b97c99aaec3beeceb9677537f9c68fef619924c29a742
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/60.5.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6
|
Release files / obj_encrypt-0.7.0-py3-none-any.whl
| Download URL | obj_encrypt-0.7.0-py3-none-any.whl |
|---|---|
| Size | 4.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e0e7b56a8ee948a2cdebfa1127f374418f7c6ba11744549cb39955a3db90cacc
|
|
BLAKE2b-256 checksum How to use checksums |
934ef9ba39f76dc43501dca20165c6d10f2b0689750ca591e68088c456b096e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/60.5.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.6
|