| 57 | } |
| 58 | |
| 59 | auto ProviderCapabilities::hash(Provider p, QIODevice* device, QString type) -> QString |
| 60 | { |
| 61 | QCryptographicHash::Algorithm algo = QCryptographicHash::Sha1; |
| 62 | switch (p) { |
| 63 | case Provider::MODRINTH: { |
| 64 | algo = (type == "sha1") ? QCryptographicHash::Sha1 : QCryptographicHash::Sha512; |
| 65 | break; |
| 66 | } |
| 67 | case Provider::FLAME: |
| 68 | algo = (type == "sha1") ? QCryptographicHash::Sha1 : QCryptographicHash::Md5; |
| 69 | break; |
| 70 | } |
| 71 | |
| 72 | QCryptographicHash hash(algo); |
| 73 | if(!hash.addData(device)) |
| 74 | qCritical() << "Failed to read JAR to create hash!"; |
| 75 | |
| 76 | Q_ASSERT(hash.result().length() == hash.hashLength(algo)); |
| 77 | return { hash.result().toHex() }; |
| 78 | } |
| 79 | |
| 80 | } // namespace ModPlatform |
no test coverage detected