You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
fromcryptography.hazmat.backendsimportdefault_backendfromcryptography.hazmat.primitives.ciphers.algorithmsimportAESfromcryptography.hazmat.primitives.ciphers.modesimportECBfromaes_pkcs5.algorithmsimportAESCommon, Cipher, OUTPUT_FORMATSclassAESECBPKCS5Padding(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=keyifoutput_formatnotinOUTPUT_FORMATS:
raiseNotImplementedError(
f"Support for output format: {output_format} is not implemented"
)
self._output_format=output_formatdef_get_cipher(self):
"""Return AES/CBC/PKCS5Padding Cipher"""returnCipher(AES(self._key), mode=ECB(), backend=default_backend())
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: