I'm currently working on a launcher for minecraft with forge. The problem i'm facing now is about hashes. Vanilla's hashes are SHA1 Hashes, and that's ok.(here for example https://s3.amazonaws.com/Minecraft.Download/versions/1.7.10/1.7.10.json) I have to check hashes for forge too and i have this JSON file: https://github.com/MinecraftForge/FML/blob/master/jsons/1.7.10-rel.json. As you can see for each library there is a checksums field with two values. Now my question is: What are they? I imagine they are some kind of hashes of the files, not the names. I tried to check both SHA1 and MD5 but they are not the same. I don't even understand why there are two values. Does someone have an explanation for this?
-
http://stackoverflow.com/questions/3307146/verification-of-dependency-authenticy-in-maven-pom-based-automated-build-systems#3309802 might answer your question. not entirely sure – Tschallacka Feb 15 '16 at 13:04
1 Answers
As far as I can tell, these two checksums are MD5 and SHA1 respectively. They are related to the Maven repository that the JSON file references as per the url tag for each library. The Forge artifacts likely followed this: https://blog.packagecloud.io/eng/2017/03/09/how-does-a-maven-repository-work/#checksumasc
In short, the previous URL explains briefly how a Maven repository works and references these 2 checksums as download verification. Another reference to the creation of Maven checksums also points to them coming in pairs: Maven checksum pom setting?
Here's a plugin that can interact with the checksums: http://checksum-maven-plugin.nicoulaj.net/
tl;dr These are Maven repository checksums that comes in a MD5 and SHA1 pair. In a C# setting, there are a number of options to do verify both:
https://dzone.com/articles/generating-md5-and-sha1
public static void ComputeMD5Hash(object filePath) { using (var stream = new FileStream((string)filePath, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (var md5gen = new MD5CryptoServiceProvider()) { md5gen.ComputeHash(stream); Program.MD5Hash = BitConverter.ToString(md5gen.Hash).Replace("-", "").ToLower(); } } }
- Calculate MD5 checksum for a file

- 24
- 1
- 1
- 5