QCryptographicHash: Add getter for algorithm()
This can be helpful when you calculate multiple hashes, store them in a vector and you want to know which result belongs to which algorithm. [ChangeLog][QtCore][QCryptographicHash] Added getter algorithm(). Change-Id: Ifcf78536f215619a6e2e3035a95598327d0ed733 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
358248b495
commit
cd37a773ca
@ -364,6 +364,16 @@ void QCryptographicHash::reset() noexcept
|
|||||||
d->reset();
|
d->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the algorithm used to generate the cryptographic hash.
|
||||||
|
|
||||||
|
\since 6.5
|
||||||
|
*/
|
||||||
|
QCryptographicHash::Algorithm QCryptographicHash::algorithm() const noexcept
|
||||||
|
{
|
||||||
|
return d->method;
|
||||||
|
}
|
||||||
|
|
||||||
void QCryptographicHashPrivate::reset() noexcept
|
void QCryptographicHashPrivate::reset() noexcept
|
||||||
{
|
{
|
||||||
switch (method) {
|
switch (method) {
|
||||||
|
@ -71,6 +71,7 @@ public:
|
|||||||
void swap(QCryptographicHash &other) noexcept { qt_ptr_swap(d, other.d); }
|
void swap(QCryptographicHash &other) noexcept { qt_ptr_swap(d, other.d); }
|
||||||
|
|
||||||
void reset() noexcept;
|
void reset() noexcept;
|
||||||
|
[[nodiscard]] Algorithm algorithm() const noexcept;
|
||||||
|
|
||||||
#if QT_DEPRECATED_SINCE(6, 4)
|
#if QT_DEPRECATED_SINCE(6, 4)
|
||||||
QT_DEPRECATED_VERSION_X_6_4("Use the QByteArrayView overload instead")
|
QT_DEPRECATED_VERSION_X_6_4("Use the QByteArrayView overload instead")
|
||||||
|
@ -51,6 +51,8 @@ void tst_QCryptographicHash::repeated_result()
|
|||||||
QCryptographicHash::Algorithm _algo = QCryptographicHash::Algorithm(algo);
|
QCryptographicHash::Algorithm _algo = QCryptographicHash::Algorithm(algo);
|
||||||
QCryptographicHash hash(_algo);
|
QCryptographicHash hash(_algo);
|
||||||
|
|
||||||
|
QCOMPARE_EQ(hash.algorithm(), _algo);
|
||||||
|
|
||||||
QFETCH(QByteArray, first);
|
QFETCH(QByteArray, first);
|
||||||
hash.addData(first);
|
hash.addData(first);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user