Encryption and decryption tools. Cipher mix AES encryption with base64 encode generating plain text encrypted files.
Usage
variables:
>>> import cipher
>>> cipher.encrypt("encryption_password", "something to encrypt!")
'WDJoMWJYVXhkWE5mWlc1algxOGNSc2hFT1o2ZGRBOGhoWnByQjYzZnZBYlp3N2ZKZmVDTEw2V1ZEMWlhZ0ZyZDVpSnpVZDll'
>>> import cipher
>>> encrypted = cipher.encrypt("encryption_password", "something to encrypt!")
>>> cipher.decrypt("encryption_password", encrypted)
'something to encrypt!'
files:
>>> import cipher
>>> txt = "file content to encrypt!"
>>> cipher.write("/tmp/file.encrypted", "encryption_password", txt)
>>> import cipher
>>> cipher.read("/tmp/file.encrypted", "encryption_password")
'file content to encrypt!'
A Credentials class can be used to handle secrets stored in JSON formats:
>>> import json
>>> secrets = {
... "db_dsn": "mysql://user:pass@host:port/dbname",
... "api_token": "some token"
... }
>>> cipher.write("/tmp/secrets", "encryption_password", json.dumps(secrets))
>>>
>>> # so, in your app you can do something like this:
>>> import cipher
>>> cred = cipher.Credentials("/tmp/secrets", "encryption_password")
>>> cred.db_dsn
'mysql://user:pass@host:port/dbname'
>>> cred.api_token
'some token'
Generating keys
There are a lot of ways to create keys but a good easy to use way to create non-easy to remember keys is using /dev/urandom, almost on Unix systems. For example:
dd if=/dev/urandom bs=16 count=1 | base64 > /path/to/key_file
The count parameter is the number of blocks to read and write, while the bs parameter is the size of each block.
CLI
There is also available a nice command line. Just install cipher and start using it! $ ciphercmd -v will let you know it is ready to be used.
Installation
PyPi:
$ pip install humu1us-cipher
Development version:
$ git clone git@github.com:humu1us/cipher.git $ cd cipher $ pip install -e .
Contribution
Contributions are welcome! Feel free to report bugs or open an issue if you feel a new feature is needed. Pull requests are welcome!
Metadata
Release files for humu1us-cipher 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| humu1us-cipher-1.0.1.tar.gz | 8.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| humu1us_cipher-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.5 kB
Release files / humu1us-cipher-1.0.1.tar.gz
| Download URL | humu1us-cipher-1.0.1.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7fe735612bdf8e66b8442fdaf0b50799e12c1eab3a5add8d72b78b734deb4135
|
|
BLAKE2b-256 checksum How to use checksums |
f08fece44af5e674e1f43dbc1ef8a874fc958f417f0159324919f0350935b92e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.4
|
Release files / humu1us_cipher-1.0.1-py3-none-any.whl
| Download URL | humu1us_cipher-1.0.1-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c2224bd76bd0480404461234cccfcfeefb263c54a056cffb2f8df74167e1e0d3
|
|
BLAKE2b-256 checksum How to use checksums |
67ef7dd359e887a3439a369757ec753272dc510824787c7e2fde0810e236bdab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.4
|