From de437b905b44ce27455cae2fed7be6918fbaed26 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 6 Dec 2018 17:23:28 +0800 Subject: [PATCH] Fix MSVC C4267 warning The warning was: "warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data" --- src/base/utils/password.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/base/utils/password.cpp b/src/base/utils/password.cpp index bced8359e..ec9257ab5 100644 --- a/src/base/utils/password.cpp +++ b/src/base/utils/password.cpp @@ -78,16 +78,16 @@ QByteArray Utils::Password::PBKDF2::generate(const QByteArray &password) std::array outBuf {}; const int hmacResult = PKCS5_PBKDF2_HMAC(password.constData(), password.size() - , reinterpret_cast(salt.data()), (sizeof(salt[0]) * salt.size()) + , reinterpret_cast(salt.data()), static_cast(sizeof(salt[0]) * salt.size()) , hashIterations, hashMethod - , outBuf.size(), outBuf.data()); + , static_cast(outBuf.size()), outBuf.data()); if (hmacResult != 1) return {}; const QByteArray saltView = QByteArray::fromRawData( - reinterpret_cast(salt.data()), (sizeof(salt[0]) * salt.size())); + reinterpret_cast(salt.data()), static_cast(sizeof(salt[0]) * salt.size())); const QByteArray outBufView = QByteArray::fromRawData( - reinterpret_cast(outBuf.data()), outBuf.size()); + reinterpret_cast(outBuf.data()), static_cast(outBuf.size())); return (saltView.toBase64() + ':' + outBufView.toBase64()); } @@ -110,11 +110,11 @@ bool Utils::Password::PBKDF2::verify(const QByteArray &secret, const QByteArray const int hmacResult = PKCS5_PBKDF2_HMAC(password.constData(), password.size() , reinterpret_cast(salt.constData()), salt.size() , hashIterations, hashMethod - , outBuf.size(), outBuf.data()); + , static_cast(outBuf.size()), outBuf.data()); if (hmacResult != 1) return false; const QByteArray outBufView = QByteArray::fromRawData( - reinterpret_cast(outBuf.data()), outBuf.size()); + reinterpret_cast(outBuf.data()), static_cast(outBuf.size())); return slowEquals(key, outBufView); }