=========
asymcrypt
=========
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