| 62 | |
| 63 | |
| 64 | int EnCrypt::runner(QString &result, QString text, QString passphrase, QString method, int keylen) { |
| 65 | |
| 66 | // Run the Java program to decrypt the text. This is an extremely ugly |
| 67 | // hack, but I haven't been able to get anything else to work. |
| 68 | QString jar = global.fileManager.getJavaDirPath("") + "crypto.jar"; |
| 69 | |
| 70 | QProcess javaProcess; |
| 71 | QStringList args; |
| 72 | args.append("-jar"); |
| 73 | args.append(jar); |
| 74 | args.append(method); |
| 75 | args.append(passphrase); |
| 76 | args.append(QString::number(keylen)); |
| 77 | args.append(text); |
| 78 | javaProcess.start("java", args); |
| 79 | |
| 80 | result.clear(); |
| 81 | javaProcess.waitForFinished(); |
| 82 | int rc = javaProcess.exitCode(); |
| 83 | QLOG_DEBUG() << "Return Code: " << rc; |
| 84 | if (rc == 0) |
| 85 | result.append(javaProcess.readAllStandardOutput()); |
| 86 | |
| 87 | return rc; |
| 88 | |
| 89 | // tidyProcess.start("tidy -raw -asxhtml -q -m -u -utf8 ", QIODevice::ReadWrite|QIODevice::Unbuffered); |
| 90 | // QLOG_DEBUG() << "Starting tidy " << tidyProcess.waitForStarted(); |
| 91 | // tidyProcess.waitForStarted(); |
| 92 | // tidyProcess.write(content); |
| 93 | // tidyProcess.closeWriteChannel(); |
| 94 | // tidyProcess.waitForFinished(); |
| 95 | // QLOG_DEBUG() << "Stopping tidy " << tidyProcess.waitForFinished() << " Return Code: " << tidyProcess.state(); |
| 96 | // QLOG_DEBUG() << "Tidy Errors:" << tidyProcess.readAllStandardError(); |
| 97 | // content.clear(); |
| 98 | // content.append(tidyProcess.readAllStandardOutput()); |
| 99 | // if (content == "") { |
| 100 | // formattingError = true; |
| 101 | // return ""; |
| 102 | // } |
| 103 | |
| 104 | |
| 105 | // Below is a botan test |
| 106 | // QByteArray hash = QCryptographicHash::hash(passphrase.toUtf8(),QCryptographicHash::Md5); |
| 107 | // SymmetricKey key; |
| 108 | // key.change(QString(hash.toHex()).toStdString()); |
| 109 | // qDebug() << "Key:" << QString::fromStdString(key.as_string()); |
| 110 | |
| 111 | // try { |
| 112 | // Keyed_Filter *cipher = get_cipher("RC2/ECB/NoPadding", DECRYPTION); |
| 113 | // cipher->set_key(key); |
| 114 | // Pipe pipe(new Base64_Decoder, cipher); |
| 115 | // byte *in = (byte*)text.data(); |
| 116 | // QLOG_DEBUG() << text.length(); |
| 117 | // pipe.process_msg(in, text.length()); |
| 118 | // SecureVector<byte> sv = pipe.read_all(); |
| 119 | // QByteArray x1 = QByteArray::fromRawData((const char*)sv.begin(), sv.size()); |
| 120 | // QLOG_DEBUG() << x1; |
| 121 | // QLOG_DEBUG() << x1.toHex(); |
no test coverage detected