From 66dcb13b5a1450cfb5ec56042a9a5078c00de9bb Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Fri, 27 Jul 2018 12:03:32 -0400 Subject: [PATCH] Rename some stuff for clarity. --- .../velocitypowered/proxy/util/EncryptionUtils.java | 4 ++-- .../proxy/util/EncryptionUtilsTest.java | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/velocitypowered/proxy/util/EncryptionUtils.java b/src/main/java/com/velocitypowered/proxy/util/EncryptionUtils.java index c5b825419..226a24130 100644 --- a/src/main/java/com/velocitypowered/proxy/util/EncryptionUtils.java +++ b/src/main/java/com/velocitypowered/proxy/util/EncryptionUtils.java @@ -17,7 +17,7 @@ public enum EncryptionUtils { } } - public static String twosComplementSha1Digest(byte[] digest) { + public static String twosComplementHexdigest(byte[] digest) { return new BigInteger(digest).toString(16); } @@ -32,7 +32,7 @@ public enum EncryptionUtils { MessageDigest digest = MessageDigest.getInstance("SHA-1"); digest.update(sharedSecret); digest.update(key.getEncoded()); - return twosComplementSha1Digest(digest.digest()); + return twosComplementHexdigest(digest.digest()); } catch (NoSuchAlgorithmException e) { throw new AssertionError(e); } diff --git a/src/test/java/com/velocitypowered/proxy/util/EncryptionUtilsTest.java b/src/test/java/com/velocitypowered/proxy/util/EncryptionUtilsTest.java index 5f0c53602..ae3e03e2f 100644 --- a/src/test/java/com/velocitypowered/proxy/util/EncryptionUtilsTest.java +++ b/src/test/java/com/velocitypowered/proxy/util/EncryptionUtilsTest.java @@ -9,18 +9,18 @@ import static org.junit.jupiter.api.Assertions.assertEquals; class EncryptionUtilsTest { @Test - void twosComplementSha1Digest() throws Exception { - String notchHash = hexDigest("Notch"); + void twosComplementHexdigest() throws Exception { + String notchHash = mojangLoginSha1("Notch"); assertEquals("4ed1f46bbe04bc756bcb17c0c7ce3e4632f06a48", notchHash); - String jebHash = hexDigest("jeb_"); + String jebHash = mojangLoginSha1("jeb_"); assertEquals("-7c9d5b0044c130109a5d7b5fb5c317c02b4e28c1", jebHash); } - private String hexDigest(String str) throws Exception { + private String mojangLoginSha1(String str) throws Exception { MessageDigest digest = MessageDigest.getInstance("SHA-1"); digest.update(str.getBytes(StandardCharsets.UTF_8)); byte[] digested = digest.digest(); - return EncryptionUtils.twosComplementSha1Digest(digested); + return EncryptionUtils.twosComplementHexdigest(digested); } }