Use the correct hashing algorithm
This commit is contained in:
parent
567a91f7d0
commit
2bf5eea248
|
@ -17,7 +17,6 @@ import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Base64;
|
|
||||||
|
|
||||||
@Mixin(ServerPropertiesHandler.class)
|
@Mixin(ServerPropertiesHandler.class)
|
||||||
public class ServerPropertiesHandlerMixin {
|
public class ServerPropertiesHandlerMixin {
|
||||||
|
@ -33,9 +32,11 @@ public class ServerPropertiesHandlerMixin {
|
||||||
resourcePackSha1 = "";
|
resourcePackSha1 = "";
|
||||||
if (Cfg.hashResources) {
|
if (Cfg.hashResources) {
|
||||||
try {
|
try {
|
||||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
StringBuilder result = new StringBuilder();
|
||||||
byte[] hash = digest.digest(Files.readAllBytes(DynRes.resFile));
|
for (byte b : MessageDigest.getInstance("SHA-1").digest(Files.readAllBytes(DynRes.resFile))) {
|
||||||
resourcePackSha1 = Base64.getEncoder().encodeToString(hash);
|
result.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
|
||||||
|
}
|
||||||
|
resourcePackSha1 = result.toString();
|
||||||
DynRes.LOGGER.info("Set hash to " + resourcePackSha1);
|
DynRes.LOGGER.info("Set hash to " + resourcePackSha1);
|
||||||
} catch (IOException | NoSuchAlgorithmException e) {
|
} catch (IOException | NoSuchAlgorithmException e) {
|
||||||
DynRes.LOGGER.error("Failed to get hash, continuing with empty", e);
|
DynRes.LOGGER.error("Failed to get hash, continuing with empty", e);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user