| 1 | /* |
| 2 | Copyright (c) 2011, Andre Somers |
| 3 | All rights reserved. |
| 4 | |
| 5 | Redistribution and use in source and binary forms, with or without |
| 6 | modification, are permitted provided that the following conditions are met: |
| 7 | * Redistributions of source code must retain the above copyright |
| 8 | notice, this list of conditions and the following disclaimer. |
| 9 | * Redistributions in binary form must reproduce the above copyright |
| 10 | notice, this list of conditions and the following disclaimer in the |
| 11 | documentation and/or other materials provided with the distribution. |
| 12 | * Neither the name of the Rathenau Instituut, Andre Somers nor the |
| 13 | names of its contributors may be used to endorse or promote products |
| 14 | derived from this software without specific prior written permission. |
| 15 | |
| 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 | DISCLAIMED. IN NO EVENT SHALL ANDRE SOMERS BE LIABLE FOR ANY |
| 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 22 | LOSS OF USE, DATA, OR #######; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #include "3rd-party/sc/simplecrypt.h"cxx . . $ `<file>/src/librssguard/3rd-party/sc/simplecrypt.h`/ |
| 29 | |
| 30 | #include <QByteArray> |
| 31 | #include <QCryptographicHash> |
| 32 | #include <QDataStream> |
| 33 | #include <QDateTime> |
| 34 | #include <QIODevice> |
| 35 | #include <QRandomGenerator> |
| 36 | #include <QtDebug> |
| 37 | #include <QtGlobal> |
| 38 | |
| 39 | SimpleCryptcxx . . $ SimpleCrypt#::SimpleCryptcxx . . $ SimpleCrypt#SimpleCrypt(49f6e7a06ebc5aa8).() |
| 40 | : m_keycxx . . $ SimpleCrypt#m_key.(0), m_compressionModecxx . . $ SimpleCrypt#m_compressionMode.(CompressionAlwayscxx . . $ SimpleCrypt#CompressionAlways.), m_protectionModecxx . . $ SimpleCrypt#m_protectionMode.(ProtectionHashcxx . . $ SimpleCrypt#ProtectionHash.), m_lastErrorcxx . . $ SimpleCrypt#m_lastError.(ErrorNoErrorcxx . . $ SimpleCrypt#ErrorNoError.) {} |
| 41 | |
| 42 | SimpleCryptcxx . . $ SimpleCrypt#::SimpleCryptcxx . . $ SimpleCrypt#SimpleCrypt(891dc3055356b409).(quint64cxx . . $ quint64# key) |
| 43 | : m_keycxx . . $ SimpleCrypt#m_key.(key), m_compressionModecxx . . $ SimpleCrypt#m_compressionMode.(CompressionAlwayscxx . . $ SimpleCrypt#CompressionAlways.), m_protectionModecxx . . $ SimpleCrypt#m_protectionMode.(ProtectionHashcxx . . $ SimpleCrypt#ProtectionHash.), m_lastErrorcxx . . $ SimpleCrypt#m_lastError.(ErrorNoErrorcxx . . $ SimpleCrypt#ErrorNoError.) { |
| 44 | splitKeycxx . . $ SimpleCrypt#splitKey(49f6e7a06ebc5aa8).(); |
| 45 | } |
| 46 | |
| 47 | void SimpleCryptcxx . . $ SimpleCrypt#::setKeycxx . . $ SimpleCrypt#setKey(891dc3055356b409).(quint64cxx . . $ quint64# key) { |
| 48 | m_keycxx . . $ SimpleCrypt#m_key. = key; |
| 49 | splitKeycxx . . $ SimpleCrypt#splitKey(49f6e7a06ebc5aa8).(); |
| 50 | } |
| 51 | |
| 52 | void SimpleCryptcxx . . $ SimpleCrypt#::splitKeycxx . . $ SimpleCrypt#splitKey(49f6e7a06ebc5aa8).() { |
| 53 | m_keyPartscxx . . $ SimpleCrypt#m_keyParts..clearcxx . . $ QList#clear(49f6e7a06ebc5aa8).(); |
| 54 | m_keyPartscxx . . $ SimpleCrypt#m_keyParts..resizecxx . . $ QList#resize(35cb52607f6af42f).(8); |
| 55 | |
| 56 | for (int i = 0; i < 8; i++) { |
| 57 | quint64cxx . . $ quint64# part = m_keycxx . . $ SimpleCrypt#m_key.; |
| 58 | |
| 59 | for (int j = i; j > 0; j--) { |
| 60 | part = part >> 8; |
| 61 | } |
| 62 | |
| 63 | part = part & 0xff; |
| 64 | m_keyPartscxx . . $ SimpleCrypt#m_keyParts.[cxx . . $ QList#`operator[]`(f5945173c490e616).i] = static_cast<char>(part); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | QByteArraycxx . . $ QByteArray# SimpleCryptcxx . . $ SimpleCrypt#::encryptToByteArraycxx . . $ SimpleCrypt#encryptToByteArray(743b31b35d83e992).(const QStringcxx . . $ QString#& plaintext) { |
| 69 | return encryptToByteArraycxx . . $ SimpleCrypt#encryptToByteArray(f7bd75e5ab38c523).(plaintext.toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).()); |
| 70 | } |
| 71 | |
| 72 | QByteArraycxx . . $ QByteArray# SimpleCryptcxx . . $ SimpleCrypt#::encryptToByteArraycxx . . $ SimpleCrypt#encryptToByteArray(f7bd75e5ab38c523).(QByteArraycxx . . $ QByteArray# plaintext) { |
| 73 | if (m_keyPartscxx . . $ SimpleCrypt#m_keyParts..isEmptycxx . . $ QList#isEmpty(3482b152b9333168).()) { |
| 74 | qWarningcxx . . $ `<external>/7280663963939302026/qlogging.h:170:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "No key set."; |
| 75 | m_lastErrorcxx . . $ SimpleCrypt#m_lastError. = ErrorNoKeySetcxx . . $ SimpleCrypt#ErrorNoKeySet.; |
| 76 | return QByteArraycxx . . $ QByteArray#QByteArray(ced63f7c635d850d).(); |
| 77 | } |
| 78 | |
| 79 | QByteArraycxx . . $ QByteArray# ba = plaintextcxx . . $ QByteArray#QByteArray(6bfe0b9ef323589d).; |
| 80 | CryptoFlagscxx . . $ SimpleCrypt#CryptoFlags# flags = CryptoFlagNonecxx . . $ QFlags#QFlags(93d577a3e9528307).; |
| 81 | |
| 82 | if (m_compressionModecxx . . $ SimpleCrypt#m_compressionMode. == CompressionAlwayscxx . . $ SimpleCrypt#CompressionAlways.) { |
| 83 | ba =cxx . . $ QByteArray#`operator=`(c3d647c78c52d790). qCompresscxx . . $ qCompress(63e2544b922c0030).(ba, 9); // maximum compression |
| 84 | flags |=cxx . . $ QFlags#`operator|=`(fd64b2b07d6098e0). CryptoFlagCompressioncxx . . $ SimpleCrypt#CryptoFlagCompression.; |
| 85 | } |
| 86 | else if (m_compressionModecxx . . $ SimpleCrypt#m_compressionMode. == CompressionAutocxx . . $ SimpleCrypt#CompressionAuto.) { |
| 87 | QByteArraycxx . . $ QByteArray# compressed = qCompresscxx . . $ qCompress(63e2544b922c0030).(ba, 9); |
| 88 | |
| 89 | if (compressed.sizecxx . . $ QByteArray#size(6b0412d51016192f).() < ba.sizecxx . . $ QByteArray#size(6b0412d51016192f).()) { |
| 90 | ba =cxx . . $ QByteArray#`operator=`(acee8257ca81216f). compressed; |
| 91 | flags |=cxx . . $ QFlags#`operator|=`(fd64b2b07d6098e0). CryptoFlagCompressioncxx . . $ SimpleCrypt#CryptoFlagCompression.; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | QByteArraycxx . . $ QByteArray# integrityProtectioncxx . . $ QByteArray#QByteArray(ced63f7c635d850d).; |
| 96 | |
| 97 | if (m_protectionModecxx . . $ SimpleCrypt#m_protectionMode. == ProtectionChecksumcxx . . $ SimpleCrypt#ProtectionChecksum.) { |
| 98 | flags |=cxx . . $ QFlags#`operator|=`(fd64b2b07d6098e0). CryptoFlagChecksumcxx . . $ SimpleCrypt#CryptoFlagChecksum.; |
| 99 | QDataStreamcxx . . $ QDataStream# scxx . . $ QDataStream#QDataStream(3fbd98f63ed0505e).(&integrityProtection, QIODevicecxx . . $ QFlags#QFlags(93d577a3e9528307).::WriteOnlycxx . . $ QIODeviceBase#WriteOnly.); |
| 100 | |
| 101 | #if QT_VERSION_MAJORcxx . . $ `<external>/9758848313111604122/qconfig.h:67:9`! == 6 |
| 102 | s <<cxx . . $ QDataStream#`operator<<`(457b02f34f413eb). qChecksumcxx . . $ qChecksum(6d79e8a8305b1d27).(bacxx . . $ QByteArrayView#QByteArrayView(80d8335016fb1bdc).); |
| 103 | #else |
| 104 | s << qChecksum(ba, ba.length()); |
| 105 | #endif |
| 106 | } |
| 107 | else if (m_protectionModecxx . . $ SimpleCrypt#m_protectionMode. == ProtectionHashcxx . . $ SimpleCrypt#ProtectionHash.) { |
| 108 | flags |=cxx . . $ QFlags#`operator|=`(fd64b2b07d6098e0). CryptoFlagHashcxx . . $ SimpleCrypt#CryptoFlagHash.; |
| 109 | QCryptographicHashcxx . . $ QCryptographicHash# hashcxx . . $ QCryptographicHash#QCryptographicHash(6dbb259a8a271a31).(QCryptographicHashcxx . . $ QCryptographicHash#::Sha1cxx . . $ QCryptographicHash#Sha1.); |
| 110 | |
| 111 | hash.addDatacxx . . $ QCryptographicHash#addData(3728da27305f135e).(bacxx . . $ QByteArrayView#QByteArrayView(80d8335016fb1bdc).); |
| 112 | integrityProtection +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). hash.resultcxx . . $ QCryptographicHash#result(a96750bfbcb1fbe9).(); |
| 113 | } |
| 114 | |
| 115 | // prepend a random char to the string |
| 116 | char randomChar = char(QRandomGeneratorcxx . . $ QRandomGenerator#::globalcxx . . $ QRandomGenerator#global(2e1e8c46584af0f7).()->generatecxx . . $ QRandomGenerator#generate(db52760e79bf9054).() & 0xFF); |
| 117 | |
| 118 | ba =cxx . . $ QByteArray#`operator=`(c3d647c78c52d790). randomChar +cxx . . $ operator+(adfbdceb504720ce). integrityProtection +cxx . . $ operator+(adfbdceb504720ce). ba; |
| 119 | int pos(0); |
| 120 | char lastChar(0); |
| 121 | int cnt = ba.sizecxx . . $ QByteArray#size(6b0412d51016192f).(); |
| 122 | |
| 123 | while (pos < cnt) { |
| 124 | ba[cxx . . $ QByteArray#`operator[]`(78168207d1016c17).pos] = ba.atcxx . . $ QByteArray#at(ac5a1ee720dcf605).(pos) ^ m_keyPartscxx . . $ SimpleCrypt#m_keyParts..atcxx . . $ QList#at(c7965f769b39929).(pos % 8) ^ lastChar; |
| 125 | lastChar = ba.atcxx . . $ QByteArray#at(ac5a1ee720dcf605).(pos); |
| 126 | ++pos; |
| 127 | } |
| 128 | |
| 129 | QByteArraycxx . . $ QByteArray# resultArraycxx . . $ QByteArray#QByteArray(ced63f7c635d850d).; |
| 130 | |
| 131 | resultArray.appendcxx . . $ QByteArray#append(1815c0e4073627df).(char(0x03)); // version for future updates to algorithm |
| 132 | resultArray.appendcxx . . $ QByteArray#append(1815c0e4073627df).(char(flags)); // encryption flags |
| 133 | resultArray.appendcxx . . $ QByteArray#append(85c7caed82076bbb).(ba); |
| 134 | m_lastErrorcxx . . $ SimpleCrypt#m_lastError. = ErrorNoErrorcxx . . $ SimpleCrypt#ErrorNoError.; |
| 135 | return resultArraycxx . . $ QByteArray#QByteArray(9f1b912973d89fea).; |
| 136 | } |
| 137 | |
| 138 | QStringcxx . . $ QString# SimpleCryptcxx . . $ SimpleCrypt#::encryptToStringcxx . . $ SimpleCrypt#encryptToString(fd988a2ab94d906b).(const QStringcxx . . $ QString#& plaintext) { |
| 139 | QByteArraycxx . . $ QByteArray# plaintextArray = plaintext.toUtf8cxx . . $ QString#toUtf8(ef52b713090bc85a).(); |
| 140 | QByteArraycxx . . $ QByteArray# cypher = encryptToByteArraycxx . . $ SimpleCrypt#encryptToByteArray(f7bd75e5ab38c523).(plaintextArraycxx . . $ QByteArray#QByteArray(6bfe0b9ef323589d).); |
| 141 | QStringcxx . . $ QString# cypherString = QStringcxx . . $ QString#::fromLatin1cxx . . $ QString#fromLatin1(4e15edac36d215be).(cypher.toBase64cxx . . $ QByteArray#toBase64(8447c4bee9dd4a75).()); |
| 142 | |
| 143 | return cypherStringcxx . . $ QString#QString(28715ad661ad3cec).; |
| 144 | } |
| 145 | |
| 146 | QStringcxx . . $ QString# SimpleCryptcxx . . $ SimpleCrypt#::encryptToStringcxx . . $ SimpleCrypt#encryptToString(b928598107f8bef5).(QByteArraycxx . . $ QByteArray# plaintext) { |
| 147 | QByteArraycxx . . $ QByteArray# cypher = encryptToByteArraycxx . . $ SimpleCrypt#encryptToByteArray(f7bd75e5ab38c523).(plaintextcxx . . $ QByteArray#QByteArray(6bfe0b9ef323589d).); |
| 148 | QStringcxx . . $ QString# cypherString = QStringcxx . . $ QString#::fromLatin1cxx . . $ QString#fromLatin1(4e15edac36d215be).(cypher.toBase64cxx . . $ QByteArray#toBase64(8447c4bee9dd4a75).()); |
| 149 | |
| 150 | return cypherStringcxx . . $ QString#QString(28715ad661ad3cec).; |
| 151 | } |
| 152 | |
| 153 | QStringcxx . . $ QString# SimpleCryptcxx . . $ SimpleCrypt#::decryptToStringcxx . . $ SimpleCrypt#decryptToString(fd988a2ab94d906b).(const QStringcxx . . $ QString#& cyphertext) { |
| 154 | QByteArraycxx . . $ QByteArray# cyphertextArray = QByteArraycxx . . $ QByteArray#::fromBase64cxx . . $ QByteArray#fromBase64(f3901ce8bc17a1ca).(cyphertext.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()); |
| 155 | QByteArraycxx . . $ QByteArray# plaintextArray = decryptToByteArraycxx . . $ SimpleCrypt#decryptToByteArray(f7bd75e5ab38c523).(cyphertextArraycxx . . $ QByteArray#QByteArray(6bfe0b9ef323589d).); |
| 156 | QStringcxx . . $ QString# plaintext = QStringcxx . . $ QString#::fromUtf8cxx . . $ QString#fromUtf8(c6a27c21e014c0ef).(plaintextArray, plaintextArray.sizecxx . . $ QByteArray#size(6b0412d51016192f).()); |
| 157 | |
| 158 | return plaintextcxx . . $ QString#QString(28715ad661ad3cec).; |
| 159 | } |
| 160 | |
| 161 | QStringcxx . . $ QString# SimpleCryptcxx . . $ SimpleCrypt#::decryptToStringcxx . . $ SimpleCrypt#decryptToString(b928598107f8bef5).(QByteArraycxx . . $ QByteArray# cypher) { |
| 162 | QByteArraycxx . . $ QByteArray# ba = decryptToByteArraycxx . . $ SimpleCrypt#decryptToByteArray(f7bd75e5ab38c523).(cyphercxx . . $ QByteArray#QByteArray(6bfe0b9ef323589d).); |
| 163 | QStringcxx . . $ QString# plaintext = QStringcxx . . $ QString#::fromUtf8cxx . . $ QString#fromUtf8(c6a27c21e014c0ef).(ba, ba.sizecxx . . $ QByteArray#size(6b0412d51016192f).()); |
| 164 | |
| 165 | return plaintextcxx . . $ QString#QString(28715ad661ad3cec).; |
| 166 | } |
| 167 | |
| 168 | QByteArraycxx . . $ QByteArray# SimpleCryptcxx . . $ SimpleCrypt#::decryptToByteArraycxx . . $ SimpleCrypt#decryptToByteArray(743b31b35d83e992).(const QStringcxx . . $ QString#& cyphertext) { |
| 169 | QByteArraycxx . . $ QByteArray# cyphertextArray = QByteArraycxx . . $ QByteArray#::fromBase64cxx . . $ QByteArray#fromBase64(f3901ce8bc17a1ca).(cyphertext.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).()); |
| 170 | QByteArraycxx . . $ QByteArray# ba = decryptToByteArraycxx . . $ SimpleCrypt#decryptToByteArray(f7bd75e5ab38c523).(cyphertextArraycxx . . $ QByteArray#QByteArray(6bfe0b9ef323589d).); |
| 171 | |
| 172 | return bacxx . . $ QByteArray#QByteArray(9f1b912973d89fea).; |
| 173 | } |
| 174 | |
| 175 | QByteArraycxx . . $ QByteArray# SimpleCryptcxx . . $ SimpleCrypt#::decryptToByteArraycxx . . $ SimpleCrypt#decryptToByteArray(f7bd75e5ab38c523).(QByteArraycxx . . $ QByteArray# cypher) { |
| 176 | if (m_keyPartscxx . . $ SimpleCrypt#m_keyParts..isEmptycxx . . $ QList#isEmpty(3482b152b9333168).()) { |
| 177 | qWarningcxx . . $ `<external>/7280663963939302026/qlogging.h:170:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "No key set."; |
| 178 | m_lastErrorcxx . . $ SimpleCrypt#m_lastError. = ErrorNoKeySetcxx . . $ SimpleCrypt#ErrorNoKeySet.; |
| 179 | return QByteArraycxx . . $ QByteArray#QByteArray(ced63f7c635d850d).(); |
| 180 | } |
| 181 | |
| 182 | QByteArraycxx . . $ QByteArray# ba = cyphercxx . . $ QByteArray#QByteArray(6bfe0b9ef323589d).; |
| 183 | |
| 184 | if (cypher.sizecxx . . $ QByteArray#size(6b0412d51016192f).() < 3) { |
| 185 | return QByteArraycxx . . $ QByteArray#QByteArray(ced63f7c635d850d).(); |
| 186 | } |
| 187 | |
| 188 | char version = ba.atcxx . . $ QByteArray#at(ac5a1ee720dcf605).(0); |
| 189 | |
| 190 | if (version != 3) { // we only work with version 3 |
| 191 | m_lastErrorcxx . . $ SimpleCrypt#m_lastError. = ErrorUnknownVersioncxx . . $ SimpleCrypt#ErrorUnknownVersion.; |
| 192 | qWarningcxx . . $ `<external>/7280663963939302026/qlogging.h:170:9`!() <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Invalid version or not a cyphertext."; |
| 193 | return QByteArraycxx . . $ QByteArray#QByteArray(ced63f7c635d850d).(); |
| 194 | } |
| 195 | |
| 196 | CryptoFlagscxx . . $ SimpleCrypt#CryptoFlags# flags = CryptoFlagscxx . . $ SimpleCrypt#CryptoFlags#(bacxx . . $ QFlag#QFlag(f349c77f591a7878)..atcxx . . $ QByteArray#at(ac5a1ee720dcf605).(1)); |
| 197 | |
| 198 | ba =cxx . . $ QByteArray#`operator=`(c3d647c78c52d790). ba.midcxx . . $ QByteArray#mid(88d472d02baa9f48).(2); |
| 199 | int pos(0); |
| 200 | int cnt(ba.sizecxx . . $ QByteArray#size(6b0412d51016192f).()); |
| 201 | char lastChar = 0; |
| 202 | |
| 203 | while (pos < cnt) { |
| 204 | char currentChar = ba[cxx . . $ QByteArray#`operator[]`(78168207d1016c17).pos]; |
| 205 | |
| 206 | ba[cxx . . $ QByteArray#`operator[]`(78168207d1016c17).pos] = ba.atcxx . . $ QByteArray#at(ac5a1ee720dcf605).(pos) ^ lastChar ^ m_keyPartscxx . . $ SimpleCrypt#m_keyParts..atcxx . . $ QList#at(c7965f769b39929).(pos % 8); |
| 207 | lastChar = currentChar; |
| 208 | ++pos; |
| 209 | } |
| 210 | |
| 211 | ba =cxx . . $ QByteArray#`operator=`(c3d647c78c52d790). ba.midcxx . . $ QByteArray#mid(88d472d02baa9f48).(1); // chop off the random number at the start |
| 212 | bool integrityOk(true); |
| 213 | |
| 214 | if (flags.testFlagcxx . . $ QFlags#testFlag(b276817fac6c20d5).(CryptoFlagChecksumcxx . . $ SimpleCrypt#CryptoFlagChecksum.)) { |
| 215 | if (ba.lengthcxx . . $ QByteArray#length(6b0412d51016192f).() < 2) { |
| 216 | m_lastErrorcxx . . $ SimpleCrypt#m_lastError. = ErrorIntegrityFailedcxx . . $ SimpleCrypt#ErrorIntegrityFailed.; |
| 217 | return QByteArraycxx . . $ QByteArray#QByteArray(ced63f7c635d850d).(); |
| 218 | } |
| 219 | |
| 220 | quint16cxx . . $ quint16# storedChecksum; |
| 221 | |
| 222 | { |
| 223 | QDataStreamcxx . . $ QDataStream# scxx . . $ QDataStream#QDataStream(3fbd98f63ed0505e).(&ba, QIODevicecxx . . $ QFlags#QFlags(93d577a3e9528307).::ReadOnlycxx . . $ QIODeviceBase#ReadOnly.); |
| 224 | |
| 225 | s >>cxx . . $ QDataStream#`operator>>`(cd1e702d92039b35). storedChecksum; |
| 226 | } |
| 227 | |
| 228 | ba =cxx . . $ QByteArray#`operator=`(c3d647c78c52d790). ba.midcxx . . $ QByteArray#mid(88d472d02baa9f48).(2); |
| 229 | #if QT_VERSION_MAJORcxx . . $ `<external>/9758848313111604122/qconfig.h:67:9`! == 6 |
| 230 | quint16cxx . . $ quint16# checksum = qChecksumcxx . . $ qChecksum(6d79e8a8305b1d27).(bacxx . . $ QByteArrayView#QByteArrayView(80d8335016fb1bdc).); |
| 231 | #else |
| 232 | quint16 checksum = qChecksum(ba, ba.length()); |
| 233 | #endif |
| 234 | |
| 235 | integrityOk = (checksum == storedChecksum); |
| 236 | } |
| 237 | else if (flags.testFlagcxx . . $ QFlags#testFlag(b276817fac6c20d5).(CryptoFlagHashcxx . . $ SimpleCrypt#CryptoFlagHash.)) { |
| 238 | if (ba.lengthcxx . . $ QByteArray#length(6b0412d51016192f).() < 20) { |
| 239 | m_lastErrorcxx . . $ SimpleCrypt#m_lastError. = ErrorIntegrityFailedcxx . . $ SimpleCrypt#ErrorIntegrityFailed.; |
| 240 | return QByteArraycxx . . $ QByteArray#QByteArray(ced63f7c635d850d).(); |
| 241 | } |
| 242 | |
| 243 | QByteArraycxx . . $ QByteArray# storedHash = ba.leftcxx . . $ QByteArray#left(9aaf0c106fa0b683).(20); |
| 244 | |
| 245 | ba =cxx . . $ QByteArray#`operator=`(c3d647c78c52d790). ba.midcxx . . $ QByteArray#mid(88d472d02baa9f48).(20); |
| 246 | QCryptographicHashcxx . . $ QCryptographicHash# hashcxx . . $ QCryptographicHash#QCryptographicHash(6dbb259a8a271a31).(QCryptographicHashcxx . . $ QCryptographicHash#::Sha1cxx . . $ QCryptographicHash#Sha1.); |
| 247 | |
| 248 | hash.addDatacxx . . $ QCryptographicHash#addData(3728da27305f135e).(bacxx . . $ QByteArrayView#QByteArrayView(80d8335016fb1bdc).); |
| 249 | integrityOk = (hash.resultcxx . . $ QCryptographicHash#result(a96750bfbcb1fbe9).() ==cxx . . $ `operator==`(be1acefd00fee2fd). storedHash); |
| 250 | } |
| 251 | |
| 252 | if (!integrityOk) { |
| 253 | m_lastErrorcxx . . $ SimpleCrypt#m_lastError. = ErrorIntegrityFailedcxx . . $ SimpleCrypt#ErrorIntegrityFailed.; |
| 254 | return QByteArraycxx . . $ QByteArray#QByteArray(ced63f7c635d850d).(); |
| 255 | } |
| 256 | |
| 257 | if (flags.testFlagcxx . . $ QFlags#testFlag(b276817fac6c20d5).(CryptoFlagCompressioncxx . . $ SimpleCrypt#CryptoFlagCompression.)) { |
| 258 | ba =cxx . . $ QByteArray#`operator=`(c3d647c78c52d790). qUncompresscxx . . $ qUncompress(ba1ae99d10185369).(ba); |
| 259 | } |
| 260 | |
| 261 | m_lastErrorcxx . . $ SimpleCrypt#m_lastError. = ErrorNoErrorcxx . . $ SimpleCrypt#ErrorNoError.; |
| 262 | return bacxx . . $ QByteArray#QByteArray(9f1b912973d89fea).; |
| 263 | } |