Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/QtCore/qcryptographichash.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Copyright (C) 2021 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
0002 // Copyright (C) 2016 The Qt Company Ltd.
0003 // Copyright (C) 2013 Richard J. Moore <rich@kde.org>.
0004 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0005 
0006 #ifndef QCRYPTOGRAPHICHASH_H
0007 #define QCRYPTOGRAPHICHASH_H
0008 
0009 #include <QtCore/qbytearray.h>
0010 #include <QtCore/qobjectdefs.h>
0011 
0012 QT_BEGIN_NAMESPACE
0013 
0014 
0015 class QCryptographicHashPrivate;
0016 class QIODevice;
0017 
0018 class Q_CORE_EXPORT QCryptographicHash
0019 {
0020     Q_GADGET
0021 public:
0022     enum Algorithm {
0023 #ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1
0024         Md4,
0025         Md5,
0026 #endif
0027         Sha1 = 2,
0028 #ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1
0029         Sha224,
0030         Sha256,
0031         Sha384,
0032         Sha512,
0033 
0034         Keccak_224 = 7,
0035         Keccak_256,
0036         Keccak_384,
0037         Keccak_512,
0038         RealSha3_224 = 11,
0039         RealSha3_256,
0040         RealSha3_384,
0041         RealSha3_512,
0042 #  ifndef QT_SHA3_KECCAK_COMPAT
0043         Sha3_224 = RealSha3_224,
0044         Sha3_256 = RealSha3_256,
0045         Sha3_384 = RealSha3_384,
0046         Sha3_512 = RealSha3_512,
0047 #  else
0048         Sha3_224 = Keccak_224,
0049         Sha3_256 = Keccak_256,
0050         Sha3_384 = Keccak_384,
0051         Sha3_512 = Keccak_512,
0052 #  endif
0053 
0054         Blake2b_160 = 15,
0055         Blake2b_256,
0056         Blake2b_384,
0057         Blake2b_512,
0058         Blake2s_128,
0059         Blake2s_160,
0060         Blake2s_224,
0061         Blake2s_256,
0062 #endif
0063         NumAlgorithms
0064     };
0065     Q_ENUM(Algorithm)
0066 
0067     explicit QCryptographicHash(Algorithm method);
0068     QCryptographicHash(QCryptographicHash &&other) noexcept : d(std::exchange(other.d, nullptr)) {}
0069     ~QCryptographicHash();
0070 
0071     QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QCryptographicHash)
0072     void swap(QCryptographicHash &other) noexcept { qt_ptr_swap(d, other.d); }
0073 
0074     void reset() noexcept;
0075     [[nodiscard]] Algorithm algorithm() const noexcept;
0076 
0077 #if QT_DEPRECATED_SINCE(6, 4)
0078     QT_DEPRECATED_VERSION_X_6_4("Use the QByteArrayView overload instead")
0079     void addData(const char *data, qsizetype length);
0080 #endif
0081 #if QT_CORE_REMOVED_SINCE(6, 3)
0082     void addData(const QByteArray &data);
0083 #endif
0084     void addData(QByteArrayView data) noexcept;
0085     bool addData(QIODevice *device);
0086 
0087     QByteArray result() const;
0088     QByteArrayView resultView() const noexcept;
0089 
0090 #if QT_CORE_REMOVED_SINCE(6, 3)
0091     static QByteArray hash(const QByteArray &data, Algorithm method);
0092 #endif
0093     static QByteArray hash(QByteArrayView data, Algorithm method);
0094     static int hashLength(Algorithm method);
0095     static bool supportsAlgorithm(Algorithm method);
0096 private:
0097     Q_DISABLE_COPY(QCryptographicHash)
0098     QCryptographicHashPrivate *d;
0099 };
0100 
0101 QT_END_NAMESPACE
0102 
0103 #endif