Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Encryption/decryption library

Project description

pypi pyversion

Encryption and decryption tools. Cipher mix AES encryption with base64 encode generating plain text encrypted files.


  • variables:
>>> import cipher
>>> cipher.encrypt("encryption_password", "something to encrypt!")
>>> 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
>>>"/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
>>> 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.


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.



$ pip install humu1us-cipher

Development version:

$ git clone
$ cd cipher
$ pip install -e .


Contributions are welcome! Feel free to report bugs or open an issue if you feel a new feature is needed. Pull requests are welcome!

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for humu1us-cipher, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size humu1us_cipher-1.0.0-py3-none-any.whl (9.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size humu1us-cipher-1.0.0.tar.gz (7.1 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page