Pokemon GO - Encrypting & Decrypting Packet Data

in pokemon •  8 years ago 

This is what is needed to Encrypt and Decrypt the Pokemon Go Packet Data for new bots to work. -Unknown

import android.content.SharedPreferences;
import android.util.Base64;
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

public class PokemonGoCrypt {
private static final String ALGORITHM = "AES/CTR/NoPadding";
private static final SecureRandom secureRandom = new SecureRandom();

public static byte[] encryptPokemonGoPackets(byte[] var0, byte[] var1) {
try {
byte[] var2 = new byte[16];
secureRandom.nextBytes(var2);
SecretKeySpec var3 = new SecretKeySpec(var0, "AES");
Cipher var4 = Cipher.getInstance("AES/CTR/NoPadding");
IvParameterSpec var6 = new IvParameterSpec(var2);
var4.init(1, var3, var6);
var1 = var4.doFinal(var1);
var0 = new byte[var2.length + var1.length];
System.arraycopy(var2, 0, var0, 0, var2.length);
System.arraycopy(var1, 0, var0, var2.length, var1.length);
} catch (GeneralSecurityException var5) {
var5.printStackTrace();
var0 = new byte[0];
}

  return var0;

}

public static byte[] generateBytes() {
byte[] var0 = new byte[16];
secureRandom.nextBytes(var0);
return var0;
}

public static byte[] getPersistedByteArray(String var0) {
var0 = getPreferences().getString(var0, (String)null);
byte[] var1;
if(var0 != null) {
var1 = Base64.decode(var0, 0);
} else {
var1 = new byte[0];
}

  return var1;

}

private static SharedPreferences getPreferences() {
return BackgroundBridge.currentContext.getSharedPreferences("pgp", 0);
}

public static void persistByteArray(String var0, byte[] var1) {
String var2 = Base64.encodeToString(var1, 0);
getPreferences().edit().putString(var0, var2).commit();
}

public static byte[] decryptPokemonGoPackets(byte[] var0, byte[] var1) {
if(var1.length == 32) {
try {
SecretKeySpec var2 = new SecretKeySpec(var0, "AES");
byte[] var3 = new byte[16];
var0 = new byte[16];
System.arraycopy(var1, 0, var3, 0, 16);
System.arraycopy(var1, 16, var0, 0, 16);
Cipher var6 = Cipher.getInstance("AES/CTR/NoPadding");
IvParameterSpec var4 = new IvParameterSpec(var3);
var6.init(2, var2, var4);
var0 = var6.doFinal(var0);
return var0;
} catch (GeneralSecurityException var5) {
var5.printStackTrace();
}
}

  var0 = new byte[0];
  return var0;

}
}

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

I upvote U