MessageAuthenticationCode
Base classes
| Name |
Children |
Inherits |
QMessageAuthenticationCode PySide6.QtCore QMessageAuthenticationCode(self, method: PySide6.QtCore.QCryptographicHash.Algorithm, /, key: PySide6.QtCore.QByteArray | bytes | bytearray | memoryview \= {}) -> None |
|
|
⋔ Inheritance diagram
graph TD
3366418733["core.MessageAuthenticationCode"]
2199754565["QtCore.QMessageAuthenticationCode"]
37984305["Shiboken.Object"]
2751680898["builtins.object"]
2199754565 --> 3366418733
37984305 --> 2199754565
2751680898 --> 37984305
🛈 DocStrings
Bases: QMessageAuthenticationCode
Way to generate hash-based message authentication codes (HMAC).
Source code in prettyqt/core/messageauthenticationcode.py
| class MessageAuthenticationCode(QtCore.QMessageAuthenticationCode):
"""Way to generate hash-based message authentication codes (HMAC)."""
def __init__(
self,
method: core.cryptographichash.AlgorithmStr | QtCore.QCryptographicHash.Algorithm,
key: datatypes.ByteArrayType = b"",
):
algo = core.cryptographichash.ALGORITHM.get_enum_value(method)
super().__init__(algo, datatypes.to_bytearray(key))
def __bytes__(self):
return self.get_result()
def set_key(self, key: datatypes.ByteArrayType):
self.setKey(datatypes.to_bytearray(key))
def add_data(self, data: datatypes.ByteArrayType):
self.addData(datatypes.to_bytearray(data))
def get_result(self) -> bytes:
return bytes(self.result().data())
@staticmethod
def compute_hash(
message: datatypes.ByteArrayType,
key: datatypes.ByteArrayType,
method: core.cryptographichash.AlgorithmStr | QtCore.QCryptographicHash.Algorithm,
) -> bytes:
algo = core.cryptographichash.ALGORITHM.get_enum_value(method)
result = QtCore.QMessageAuthenticationCode.hash(
datatypes.to_bytearray(message),
datatypes.to_bytearray(key),
algo,
)
return bytes(result.data())
|
:fa-brands-github: Show source on GitHub