| 776 | } |
| 777 | |
| 778 | QString BridgeApp::decode_file(const QString &algorithm, const QString &path, const QString &key) const |
| 779 | { |
| 780 | QString filePath = path; |
| 781 | if (filePath.startsWith("~/")) |
| 782 | filePath = QDir::home().filePath(filePath.mid(2)); |
| 783 | |
| 784 | QFile file(filePath); |
| 785 | if (!file.open(QIODevice::ReadOnly)) |
| 786 | return ""; |
| 787 | |
| 788 | QByteArray encodedBytes = file.readAll(); |
| 789 | file.close(); |
| 790 | |
| 791 | QString alg = algorithm.toLower(); |
| 792 | |
| 793 | if (alg == "hex") |
| 794 | return QString::fromLatin1(QByteArray::fromHex(encodedBytes).toBase64()); |
| 795 | if (alg == "base64") |
| 796 | return QString::fromLatin1(QByteArray::fromBase64(encodedBytes).toBase64()); |
| 797 | if (alg == "base32") |
| 798 | return QString::fromLatin1(decodeBase32(encodedBytes).toBase64()); |
| 799 | if (alg == "zip") |
| 800 | return QString::fromLatin1(qUncompress(QByteArray::fromBase64(encodedBytes)).toBase64()); |
| 801 | if (alg == "xor") |
| 802 | return QString::fromLatin1(applyXor(QByteArray::fromBase64(encodedBytes), key.toUtf8()).toBase64()); |
| 803 | |
| 804 | return QString::fromLatin1(encodedBytes.toBase64()); |
| 805 | } |
| 806 | |
| 807 | // Code conversion |
| 808 |
nothing calls this directly
no test coverage detected