Skip to main content

Library for easy creation of PEP-272 cipher classes

Project description

Github Actions: QA Maintainability Test Coverage Documentation Status

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 CC0 licensed (= public domain).

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.

Source Distribution

pep272-encryption-0.4.tar.gz (14.4 kB view hashes)

Uploaded Source

Built Distributions

pep272_encryption-0.4-cp35-abi3-win_amd64.whl (18.2 kB view hashes)

Uploaded CPython 3.5+ Windows x86-64

pep272_encryption-0.4-cp35-abi3-win32.whl (17.8 kB view hashes)

Uploaded CPython 3.5+ Windows x86

pep272_encryption-0.4-cp35-abi3-manylinux1_x86_64.whl (21.5 kB view hashes)

Uploaded CPython 3.5+

pep272_encryption-0.4-cp35-abi3-manylinux1_i686.whl (21.1 kB view hashes)

Uploaded CPython 3.5+

pep272_encryption-0.4-cp35-abi3-macosx_10_9_universal2.whl (16.8 kB view hashes)

Uploaded CPython 3.5+ macOS 10.9+ universal2 (ARM64, x86-64)

pep272_encryption-0.4-cp35-abi3-macosx_10_6_intel.whl (16.6 kB view hashes)

Uploaded CPython 3.5+ macOS 10.6+ intel

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page