| 747 | } |
| 748 | |
| 749 | QString BridgeApp::encode_file(const QString &algorithm, const QString &path, const QString &key) const |
| 750 | { |
| 751 | QString filePath = path; |
| 752 | if (filePath.startsWith("~/")) |
| 753 | filePath = QDir::home().filePath(filePath.mid(2)); |
| 754 | |
| 755 | QFile file(filePath); |
| 756 | if (!file.open(QIODevice::ReadOnly)) |
| 757 | return ""; |
| 758 | |
| 759 | QByteArray bytes = file.readAll(); |
| 760 | file.close(); |
| 761 | |
| 762 | QString alg = algorithm.toLower(); |
| 763 | |
| 764 | if (alg == "hex") |
| 765 | return QString::fromLatin1(bytes.toHex()); |
| 766 | if (alg == "base64") |
| 767 | return QString::fromLatin1(bytes.toBase64()); |
| 768 | if (alg == "base32") |
| 769 | return QString::fromLatin1(encodeBase32(bytes)); |
| 770 | if (alg == "zip") |
| 771 | return QString::fromLatin1(qCompress(bytes).toBase64()); |
| 772 | if (alg == "xor") |
| 773 | return QString::fromLatin1(applyXor(bytes, key.toUtf8()).toBase64()); |
| 774 | |
| 775 | return QString::fromLatin1(bytes.toBase64()); |
| 776 | } |
| 777 | |
| 778 | QString BridgeApp::decode_file(const QString &algorithm, const QString &path, const QString &key) const |
| 779 | { |
nothing calls this directly
no test coverage detected