Skip to main content

Library for easy creation of PEP-272 cipher classes

Project description

https://img.shields.io/travis/Varbin/pep272-encryption.svg https://img.shields.io/codecov/c/github/Varbin/pep272-encryption/master.svg https://ci.appveyor.com/api/projects/status/github/Varbin/pep272-encryption?svg=true

Documentation

To prevent reinventing the wheel while creating a PEP-272 interface for a new block cipher encryption, this library aims to create an extensible framework for new libraries.

Currently following modes of operation are supported:

  • ECB
  • CBC
  • CFB
  • OFB
  • CTR

The PGP mode of operation is not supported. It may be added in the future.

Example

In this example encrypt_aes(key, block) will encrypt one block of AES while decrypt_aes(key, block) will decrypt one.

>>> from pep272_encryption import PEP272Cipher, MODE_ECB
>>> class AESCipher:
...    """
...    PEP-272 cipher class for AES
...    """
...    block_size = 16
...
...    def encrypt_block(self, key, block, **kwargs):
...        return encrypt_aes(key, block)
...
...    def decrypt_block(self, key, block, **kwargs):
...        return decrypt_aes(key, block)
...
>>> cipher = AESCipher(b'\00'*16, MODE_ECB)
>>> cipher.encrypt(b'\00'*16)
b'f\xe9K\xd4\xef\x8a,;\x88L\xfaY\xca4+.'

License

This project is licensed under CC0 (public domain).

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 pep272-encryption, version 0.3
Filename, size File type Python version Upload date Hashes
Filename, size pep272_encryption-0.3-cp27-cp27m-win32.whl (19.5 kB) File type Wheel Python version cp27 Upload date Hashes View hashes
Filename, size pep272_encryption-0.3-cp27-cp27m-win_amd64.whl (19.9 kB) File type Wheel Python version cp27 Upload date Hashes View hashes
Filename, size pep272_encryption-0.3-cp34-cp34m-win32.whl (19.5 kB) File type Wheel Python version cp34 Upload date Hashes View hashes
Filename, size pep272_encryption-0.3-cp34-cp34m-win_amd64.whl (19.9 kB) File type Wheel Python version cp34 Upload date Hashes View hashes
Filename, size pep272_encryption-0.3-cp35-cp35m-win32.whl (20.6 kB) File type Wheel Python version cp35 Upload date Hashes View hashes
Filename, size pep272_encryption-0.3-cp35-cp35m-win_amd64.whl (22.0 kB) File type Wheel Python version cp35 Upload date Hashes View hashes
Filename, size pep272_encryption-0.3-cp36-cp36m-win32.whl (20.6 kB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size pep272_encryption-0.3-cp36-cp36m-win_amd64.whl (22.0 kB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size pep272_encryption-0.3-cp37-cp37m-win32.whl (20.6 kB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size pep272_encryption-0.3-cp37-cp37m-win_amd64.whl (22.0 kB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size pep272-encryption-0.3.tar.gz (26.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page