Skip to content

CryptographicHash

Qt Base Class: QCryptographicHash

Signature: QCryptographicHash(self, method: PySide6.QtCore.QCryptographicHash.Algorithm) -> None

Base classes

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

⋔ Inheritance diagram

graph TD
  1473299796480["core.CryptographicHash"]
  1473288980832["QtCore.QCryptographicHash"]
  1473291690208["Shiboken.Object"]
  140713234304496["builtins.object"]
  1473288980832 --> 1473299796480
  1473291690208 --> 1473288980832
  140713234304496 --> 1473291690208

🛈 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())

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