Encryption at rest made easy
Project description
Encryption at rest made easy
cf-crypt is a package to help you keep all you data resting on disk secure. It make encrypting your data at rest as easy as reading and writing from a file.
>>> from cfcrypt import CryptFileTextIO
>>> with CryptFileTextIO('./my_file.crpt', 'w', encryption_key, identity_key) as fh:
... fh.write('Super secret, secret squirrel plans.')
Install
Install the package from pypi.org/project/cf-crypt using pip
$ python -m pip install cf-crypt
[...]
Successfully installed cf-crypt
Quick Start
Generate Keys
These keys are generated securely in memory.
Like all in memory variables they will disappear when your script ends. We really need our keys to stick around for as long as we want to decrypt our data.
>>> from cfcrypt.rsa.key_helpers import generate_private_key
>>> encryption_key = generate_private_key()
>>> identity_key = generate_private_key()
Save Keys
Keys can be serialized to the PEM format and saved to disk.
>>> from cfcrypt.rsa.key_helpers import private_key_to_pem_file
>>> private_key_to_pem_file('./my_encryption_key.pem', encryption_key)
>>> private_key_to_pem_file('./my_identity_key.pem', identity_key)
These PEM files are quite literally the keys to your data.
Load Keys
If you set a password on the PEM files you will need it to load them from disk.
>>> from cfcrypt.rsa.key_helpers import pem_file_to_private_key
>>> encryption_key = pem_file_to_private_key('./my_encryption_key.pem')
>>> identity_key = pem_file_to_private_key('./my_identity_key.pem')
Encrypt
Encryption is really easy, just use CryptFileTextIO like a regular file interface.
>>> from cfcrypt import CryptFileTextIO
>>> with CryptFileTextIO('./my_file.crpt', 'w', encryption_key, identity_key) as fh:
... fh.write('Super secret, secret squirrel plans.')
Decrypt
Decryption is also really easy, just use CryptFileTextIO like a regular file interface.
>>> from cfcrypt import CryptFileTextIO
>>> with CryptFileTextIO('./my_file.crpt', 'r', encryption_key, identity_key) as fh:
... data = fh.read()
>>> data
'Super secret, secret squirrel plans.'
More…
There are a bunch of other useful encryption related tools in the module. See the documentation (cf-crypt.readthedocs.io/en/latest) for details.
String encryption
Python object serialization + encryption
RSA signing & verification
File & folder encryption
Key management.
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 cf_crypt-0.1.0.dev2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 657d3d1581df379665d6cda8bae42ade86e6a60ea0916f359fce5ee31905daac |
|
MD5 | 4bcf9fbd3dd0fc15b0b0fa0f7ad417ff |
|
BLAKE2b-256 | c2efc5822699f038a14916dec0ad4d19459fb4a0480a2878616afadef09c0780 |