Last active
October 2, 2015 16:39
-
-
Save konsolas/35b6c609399544d4ede0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import me.konsolas.stuff.idk.HashMaker; | |
import javax.crypto.Cipher; | |
import javax.crypto.SecretKey; | |
import javax.crypto.spec.SecretKeySpec; | |
import java.util.Map; | |
import java.util.TreeMap; | |
public class HardToDebugHashMap { | |
private Map<String, Object> resultsMap = new TreeMap<>(); | |
public Object add(String key, Object value) { | |
String encKey; | |
try { | |
SecretKey secKey = new SecretKeySpec(HashMaker.makeHashRaw("MD5", key), "AES"); | |
Cipher aesCipher = Cipher.getInstance("AES"); | |
byte[] byteText = key.getBytes(); | |
aesCipher.init(Cipher.ENCRYPT_MODE, secKey); | |
byte[] byteCipherText = aesCipher.doFinal(byteText); | |
encKey = new String(byteCipherText); | |
} catch (Exception ex) { | |
throw new RuntimeException(ex); | |
} | |
resultsMap.put(encKey, value); | |
return this; | |
} | |
public Object get(String key) { | |
String encKey; | |
try { | |
SecretKey secKey = new SecretKeySpec(HashMaker.makeHashRaw("MD5", key), "AES"); | |
Cipher aesCipher = Cipher.getInstance("AES"); | |
byte[] byteText = key.getBytes(); | |
aesCipher.init(Cipher.ENCRYPT_MODE, secKey); | |
byte[] byteCipherText = aesCipher.doFinal(byteText); | |
encKey = new String(byteCipherText); | |
} catch (Exception ex) { | |
throw new RuntimeException(ex); | |
} | |
return resultsMap.get(encKey); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment