diff options
author | Connor-Colenso <52056774+Connor-Colenso@users.noreply.github.com> | 2024-09-19 10:58:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-19 10:58:57 +0100 |
commit | c24b78060631ea1868c06aeb3b45fd81218d379e (patch) | |
tree | 16a317c88df5e940a19c128afde43915a75a7ebf /src/main/java | |
parent | cc835e7c3792ad4e63d4bc18802472fb1a2921c4 (diff) | |
download | GT5-Unofficial-c24b78060631ea1868c06aeb3b45fd81218d379e.tar.gz GT5-Unofficial-c24b78060631ea1868c06aeb3b45fd81218d379e.tar.bz2 GT5-Unofficial-c24b78060631ea1868c06aeb3b45fd81218d379e.zip |
Remove unused class (#3228)
Co-authored-by: GTNH-Colen <54497873+GTNH-Colen@users.noreply.github.com>
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/gtPlusPlus/core/util/data/AES.java | 135 |
1 files changed, 0 insertions, 135 deletions
diff --git a/src/main/java/gtPlusPlus/core/util/data/AES.java b/src/main/java/gtPlusPlus/core/util/data/AES.java deleted file mode 100644 index 85f20a3367..0000000000 --- a/src/main/java/gtPlusPlus/core/util/data/AES.java +++ /dev/null @@ -1,135 +0,0 @@ -package gtPlusPlus.core.util.data; - -import java.io.UnsupportedEncodingException; -import java.math.BigInteger; -import java.nio.charset.StandardCharsets; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.Arrays; -import java.util.Base64; - -import javax.crypto.Cipher; -import javax.crypto.spec.SecretKeySpec; - -public class AES { - - private final String secret; - - private final SecretKeySpec secretKey; - - private final byte[] key; - - public AES() { - - this("Darkness In Their Hearts"); - } - - public AES(String aSecret) { - - secret = aSecret; - - key = getBytes(getHashedString(secret)); - - secretKey = generateKey(key); - } - - private static String getHashedString(String aString) { - - return toHexString(getSHA(aString)); - } - - private static byte[] getSHA(String input) { - - MessageDigest md; - - try { - - md = MessageDigest.getInstance("SHA-256"); - - return md.digest(input.getBytes(StandardCharsets.UTF_8)); - - } catch (NoSuchAlgorithmException e) { - - e.printStackTrace(); - } - - return new byte[] {}; - } - - private static String toHexString(byte[] hash) { - - BigInteger number = new BigInteger(1, hash); - - StringBuilder hexString = new StringBuilder(number.toString(16)); - - while (hexString.length() < 32) { - - hexString.insert(0, '0'); - } - - return hexString.toString(); - } - - private byte[] getBytes(String aKey) { - - byte[] aKeyData; - - MessageDigest sha; - - try { - - sha = MessageDigest.getInstance("SHA-256"); - - return sha.digest(aKey.getBytes(StandardCharsets.UTF_8)); - - } catch (NoSuchAlgorithmException e1) { - - e1.printStackTrace(); - - try { - - aKeyData = aKey.getBytes("UTF-8"); - - sha = MessageDigest.getInstance("SHA-1"); - - aKeyData = sha.digest(key); - - aKeyData = Arrays.copyOf(key, 16); - - return aKeyData; - - } catch (NoSuchAlgorithmException | UnsupportedEncodingException e) { - - e.printStackTrace(); - - } - } - - return new byte[] {}; - } - - private SecretKeySpec generateKey(byte[] aKey) { - - return new SecretKeySpec(aKey, "AES"); - } - - public String decode(String strToDecrypt) { - - try { - - Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING"); - - cipher.init(Cipher.DECRYPT_MODE, secretKey); - - return new String( - cipher.doFinal( - Base64.getDecoder() - .decode(strToDecrypt))); - - } catch (Exception ignored) { - - } - - return null; - } -} |