1
0
mirror of https://github.com/RipMeApp/ripme.git synced 2025-08-27 15:49:50 +02:00

Updater now works on java 9 and 10

This commit is contained in:
cyian-1756
2018-10-30 18:08:48 -04:00
parent 4acfb57b9c
commit c33e09eaca

View File

@@ -198,7 +198,7 @@ public class UpdateUtils {
}
// Code take from https://stackoverflow.com/a/30925550
private static String createSha256(File file) {
public static String createSha256(File file) {
try {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
InputStream fis = new FileInputStream(file);
@@ -210,8 +210,14 @@ public class UpdateUtils {
digest.update(buffer, 0, n);
}
}
byte[] hash = digest.digest();
StringBuilder sb = new StringBuilder(2 * hash.length);
for (byte b : hash) {
sb.append("0123456789ABCDEF".charAt((b & 0xF0) >> 4));
sb.append("0123456789ABCDEF".charAt((b & 0x0F)));
}
// As patch.py writes the hash in lowercase this must return the has in lowercase
return new HexBinaryAdapter().marshal(digest.digest()).toLowerCase();
return sb.toString().toLowerCase();
} catch (NoSuchAlgorithmException e) {
logger.error("Got error getting file hash " + e.getMessage());
} catch (FileNotFoundException e) {