Skip to content

Varbin/pep272-encryption

Repository files navigation

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

About

Library for easy creation of PEP-272 cipher classes

Resources

License

Stars

Watchers

Forks

Packages

No packages published