MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / hash

Method hash

launcher/modplatform/ModIndex.cpp:59–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59auto 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

Callers 1

executeTaskMethod · 0.45

Calls 2

lengthMethod · 0.80
resultMethod · 0.45

Tested by

no test coverage detected