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.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Base64;
|
||||
|
||||
@Mixin(ServerPropertiesHandler.class)
|
||||
public class ServerPropertiesHandlerMixin {
|
||||
@ -33,9 +32,11 @@ public class ServerPropertiesHandlerMixin {
|
||||
resourcePackSha1 = "";
|
||||
if (Cfg.hashResources) {
|
||||
try {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
byte[] hash = digest.digest(Files.readAllBytes(DynRes.resFile));
|
||||
resourcePackSha1 = Base64.getEncoder().encodeToString(hash);
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (byte b : MessageDigest.getInstance("SHA-1").digest(Files.readAllBytes(DynRes.resFile))) {
|
||||
result.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
|
||||
}
|
||||
resourcePackSha1 = result.toString();
|
||||
DynRes.LOGGER.info("Set hash to " + resourcePackSha1);
|
||||
} catch (IOException | NoSuchAlgorithmException e) {
|
||||
DynRes.LOGGER.error("Failed to get hash, continuing with empty", e);
|
||||
|
Loading…
Reference in New Issue
Block a user