Encryption Tools for Python 3
Tools for encryption and decryption, signing and verification. Use symmetric and asymmetric (RSA-based) encryption.
Installation
pip install encryptiontools
Usage
Asymmetric encryption and decryption
from encryptiontools.encryption import AsymmetricEncrypter, AsymmetricDecrypter
from encryptiontools.utils import generate_key_pair
public_key, private_key = generate_key_pair(512)
data = {'message': 'hello asymmetric encryption'}
encrypter = AsymmetricEncrypter.create(public_key.save_pkcs1()) # or AsymmetricEncrypter(public_key)
decrypter = AsymmetricDecrypter.create(private_key.save_pkcs1()) # or AsymmetricDecrypter(private_key)
encrypted = encrypter.encrypt(data)
decrypted = decrypter.decrypt(encrypted)
assert decrypted['message'] == 'hello asymmetric encryption'
Symmetric encryption and decryption
from encryptiontools.encryption import SymmetricEncrypter
key = b'0123456789abcdef'
data = {'message': 'hello symmetric encryption'}
encrypter = SymmetricEncrypter.create(key) # or SymmetricEncrypter(key)
encrypted = encrypter.encrypt(data)
decrypted = encrypter.decrypt(encrypted)
assert decrypted['message'] == 'hello symmetric encryption'
Combined encryption and decryption
Asymmetric key pair is used to encrypt/decrypt internal (symmetric) key, internal key is used to decrypt data.
from encryptiontools.encryption import CombinedEncrypter, CombinedDecrypter
from encryptiontools.utils import generate_key_pair
public_key, private_key = generate_key_pair(512)
data = {'message': 'hello combined encryption'}
encrypter = CombinedEncrypter.create(public_key.save_pkcs1()) # or CombinedEncrypter(public_key)
decrypter = CombinedDecrypter.create(private_key.save_pkcs1()) # or CombinedDecrypter(private_key)
encrypted = encrypter.encrypt(data)
decrypted = decrypter.decrypt(encrypted)
assert decrypted['message'] == 'hello combined encryption'
Signing and verification
from encryptiontools.signature import Signer, Verifier
from encryptiontools.utils import generate_key_pair
from encryptiontools.exceptions import VerificationError
public_key, private_key = generate_key_pair(512)
data = {'message': 'hello signing and verification'}
signer = Signer.create(private_key.save_pkcs1()) # or Signer(private_key)
verifier = Verifier.create(public_key.save_pkcs1()) # or Verifier(public_key)
signature = signer.sign(data)
try:
verifier.verify(data, signature)
assert True
except VerificationError:
assert False
Metadata
Release files for encryptiontools 1.0.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 | Provenance | Actions |
|---|---|---|---|---|
| encryptiontools-1.0.0.tar.gz | 6.9 kB | Without provenance | Details for encryptiontools-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| encryptiontools-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for encryptiontools-1.0.0-py3-none-any.whl |
Total release size: 13.7 kB
Release files / encryptiontools-1.0.0.tar.gz
| Download URL | encryptiontools-1.0.0.tar.gz |
|---|---|
| Size | 6.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e58547e4dabc59e750f2e7a690d2efec3181cd26d1bbc41a5b24587068154be
|
|
BLAKE2b-256 checksum How to use checksums |
b730fd2f1fa30163f283b177acc330d5f5907713cd2c395a5dbb1510b4418e12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Release files / encryptiontools-1.0.0-py3-none-any.whl
| Download URL | encryptiontools-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
41f65b88178d582f08f890091b8f229a5fa83500f1acbe0f224315cf88a6bacd
|
|
BLAKE2b-256 checksum How to use checksums |
64c4c758efc105f80b2b8f5150b84b9444d76cedd7f88725f19937c22d95bf0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Security for encryptiontools 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.