Super easy asymmetric encryption for python
Project description
Super easy asymmetric encryption for python
Introduction
python-asymcrypt is a wrapper around pycryptodome to make it even more easier for asymmetric encryption.
Installation
With pip
pip install asymcrypt
Usage
Generate keys files
import asymcrypt asymcrypt.generate_keys('my_private_key_file.pem','my_public_key_file.pem')
Encrypt data
data = 'A string, not an unicode' encrypted_data = asymcrypt.encrypt_data(data,'my_public_key_file.pem')
Decrypt data
data = asymcrypt.decrypt_data(encrypted_data,'my_private_key_file.pem')
Unicode, Str, Bytes
asymcrypt is using pycryptodome which is awaiting, for data, bytes for python3 or str for python2. So it is preferable to use these types. Nevertheless, asymcrypt provides a type detection, it will keep the type you used at encryption time for the decryption time :
For python 2, if you use unicode data for encryption, it will be automatically encoded as utf-8 str before encryption and decoded back to unicode after decryption. If you use str data, no encoding/decoding will be done.
For python 3, if you use str data for encryption, it will be automatically encoded as utf-8 bytes before encryption and decoded back to str after decryption. If you use bytes data, no encoding/decoding will be done.
Passphrase
As an option, you can use passphrase option in each functions to generate encrypted keys and read them when using encrypt/decrypt_data() functions
Base64
By default, output/input are binary. Nevertheless, you can encode into base64 in encrypt_data() by using option out_format='base64' or decode from base64 in decrypt_data() by using option in_format='base64'
Command line
Asymcrypt provides 3 commands :
To generate keys pair
asymgenkeys -priv private_key.pem -pub public_key.pem
To encrypt
asymencrypt -k public_key.pem -in file_to_encrypt.txt -out dest_file.enc
To decrypt
asymdecrypt -k private_key.pem -in encrypted_file.enc -out dest_file.txt
Note : you may use option -b or --base64 to encode/decode in base64 and -p or --passphrase to specify a passphrase to encrypt/decrypt keys
Note 2 : If you do not specify -in or -out in above commands, the standard input/output will be used.
Compatibility with openssl
asymcrypt uses RSA keys, RSA encryption protocol according to PKCS#1 OAEP, AES with EAX AEAD mode. The keys will be encrypted with scrypt And AES128-CBC if a passphrase is provided. The encrypted data keep track of the original python data type. All these make impossible to use openssl directly to decode files generated by asymcrypt.
News
0.0.10 (2019-05-24)
Use Python 3.6 in Pipfile
0.0.9 (2019-02-06)
fix asymdecrypt script
0.0.6 (2018-10-02)
Keep track of orginal data type (unicode, str, bytes)
0.0.4 (2018-10-01)
Add console commands
Keys files are now cached
0.0.2 (2018-09-28)
First running version
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
File details
Details for the file asymcrypt-0.0.10.tar.gz
.
File metadata
- Download URL: asymcrypt-0.0.10.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/2.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 979330491f2f79257d128d8e71ea9b7237124a5955316a19a8f176190c71396a |
|
MD5 | a25b3a1a0f477a7301de84a3bfd9962f |
|
BLAKE2b-256 | a075ee64d99d0815d1d6a78fc903d3feefce99e8e27f059ca11579c0dc635eb7 |
File details
Details for the file asymcrypt-0.0.10-py2.py3-none-any.whl
.
File metadata
- Download URL: asymcrypt-0.0.10-py2.py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/2.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99f82953937862c4084ec055582ffb102be3719f6e4d8d4bb0a8fe91d8eab5ae |
|
MD5 | f7cfcba7f1779c6388e5d9aadb180595 |
|
BLAKE2b-256 | da0ba44d64bc9bc6d85311c0368c2a12041911c4e71e00d30438af9b8a3ad3b9 |