encrypt note decrypted before
| 203 | |
| 204 | // encrypt note decrypted before |
| 205 | bool WizZiwReader::encryptDataToFile(const QByteArray& sourceData, \ |
| 206 | const QString& destFileName) |
| 207 | { |
| 208 | //random password |
| 209 | QString ziwPassword = WizGenGUIDLowerCaseLetterOnly() + WizGenGUIDLowerCaseLetterOnly(); |
| 210 | // |
| 211 | // encrypt data |
| 212 | QByteArray outBytes; |
| 213 | if (!WizAESEncryptToString((const unsigned char *)(ziwPassword.toUtf8().constData()), sourceData, outBytes)) { |
| 214 | return false; |
| 215 | } |
| 216 | |
| 217 | WIZZIWHEADER header; |
| 218 | initZiwHeader(header, ziwPassword); |
| 219 | |
| 220 | QFile destFile(destFileName); |
| 221 | if (!destFile.open(QIODevice::WriteOnly | QIODevice::Truncate)) { |
| 222 | TOLOG("Can't open dest file while encrypt to temp file"); |
| 223 | return false; |
| 224 | } |
| 225 | |
| 226 | QDataStream out(&destFile); |
| 227 | if (sizeof(header) != out.writeRawData((const char *)&header, sizeof(header))) { |
| 228 | TOLOG("Write data failed while encrypt to temp file"); |
| 229 | destFile.remove(); |
| 230 | return false; |
| 231 | } |
| 232 | |
| 233 | if (outBytes.length() != out.writeRawData(outBytes.constData(), outBytes.length())) { |
| 234 | TOLOG("Write data failed while encrypt to temp file"); |
| 235 | destFile.remove(); |
| 236 | return false; |
| 237 | } |
| 238 | |
| 239 | destFile.close(); |
| 240 | |
| 241 | return true; |
| 242 | } |
| 243 | |
| 244 | |
| 245 | bool WizZiwReader::encryptFileToFile(const QString& sourceFileName, \ |
no test coverage detected