Skip to content

CryptographicHash

Base classes

Name Children Inherits
QCryptographicHash
PySide6.QtCore
QCryptographicHash(self, method: PySide6.QtCore.QCryptographicHash.Algorithm, /) -> None

⋔ Inheritance diagram

graph TD
  980415833["core.CryptographicHash"]
  3498505204["QtCore.QCryptographicHash"]
  37984305["Shiboken.Object"]
  2751680898["builtins.object"]
  3498505204 --> 980415833
  37984305 --> 3498505204
  2751680898 --> 37984305

🛈 DocStrings

Bases: QCryptographicHash

Way to generate cryptographic hashes.

Source code in prettyqt/core/cryptographichash.py
class CryptographicHash(QtCore.QCryptographicHash):
    """Way to generate cryptographic hashes."""

    def __init__(self, method: QtCore.QCryptographicHash.Algorithm | AlgorithmStr):
        if isinstance(method, QtCore.QCryptographicHash.Algorithm):
            arg = method
        else:
            arg = ALGORITHM[method]
        super().__init__(arg)

    # def __str__(self):
    #     return bytes(self.result()).decode()

    def __bytes__(self):
        return self.get_result()

    def get_result(self) -> bytes:
        return bytes(self.result().data())

    @staticmethod
    def get_hash_length(
        method: AlgorithmStr | QtCore.QCryptographicHash.Algorithm,
    ) -> int:
        return CryptographicHash.hashLength(ALGORITHM.get_enum_value(method))

:fa-brands-github: Show source on GitHub