GithubHelp home page GithubHelp logo

laerte / aes_pkcs5 Goto Github PK

View Code? Open in Web Editor NEW
5.0 0.0 0.0 45 KB

Python implementation of AES with CBC/ECB mode and padding scheme PKCS5.

License: BSD 2-Clause "Simplified" License

Python 100.00%
cryptography pkcs5

aes_pkcs5's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

aes_pkcs5's Issues

Would you please support the binary secret key?

Currently the secret key must be a utf-8 encoded string but in some cases we have to use the binary secret key.
Thx if possible. For the current workaround solution, I implements my own class for anybody who may need it.

from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.ciphers.algorithms import AES
from cryptography.hazmat.primitives.ciphers.modes import ECB

from aes_pkcs5.algorithms import AESCommon, Cipher, OUTPUT_FORMATS


class AESECBPKCS5Padding(AESCommon):
    """
    Implements AES algorithm with ECB mode of operation and padding scheme PKCS5.
    """

    def __init__(self, key: bytes, output_format: str):
        super().__init__('0', output_format)
        self._key = key

        if output_format not in OUTPUT_FORMATS:
            raise NotImplementedError(
                f"Support for output format: {output_format} is not implemented"
            )

        self._output_format = output_format

    def _get_cipher(self):
        """Return AES/CBC/PKCS5Padding Cipher"""
        return Cipher(AES(self._key), mode=ECB(), backend=default_backend())

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.