Guest User

method a.a source code

a guest
Mar 21st, 2020
74
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package c.e.a.a.g;
  2.  
  3. import android.util.Log;
  4. import java.io.UnsupportedEncodingException;
  5. import java.security.GeneralSecurityException;
  6. import java.security.MessageDigest;
  7. import java.security.NoSuchAlgorithmException;
  8. import javax.crypto.Cipher;
  9. import javax.crypto.spec.IvParameterSpec;
  10. import javax.crypto.spec.SecretKeySpec;
  11.  
  12. public class a {
  13.  
  14.     /* renamed from: a reason: collision with root package name */
  15.     private static final byte[] f4797a = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  16.  
  17.     /* renamed from: b reason: collision with root package name */
  18.     public static boolean f4798b = false;
  19.  
  20.     public static String a(byte[] bArr, byte[] bArr2) throws GeneralSecurityException {
  21.         try {
  22.             byte[] a2 = a(b(bArr), f4797a, bArr2);
  23.             a("decryptedBytes", a2);
  24.             String str = new String(a2, "UTF-8");
  25.             a("message", str);
  26.             return str;
  27.         } catch (UnsupportedEncodingException e2) {
  28.             if (f4798b) {
  29.                 Log.e("AESCrypt", "UnsupportedEncodingException ", e2);
  30.             }
  31.             throw new GeneralSecurityException(e2);
  32.         }
  33.     }
  34.  
  35.     private static SecretKeySpec b(byte[] bArr) throws NoSuchAlgorithmException, UnsupportedEncodingException {
  36.         MessageDigest instance = MessageDigest.getInstance("SHA-256");
  37.         instance.update(bArr, 0, bArr.length);
  38.         byte[] digest = instance.digest();
  39.         a("SHA-256 key ", digest);
  40.         return new SecretKeySpec(digest, "AES");
  41.     }
  42.  
  43.     public static byte[] a(SecretKeySpec secretKeySpec, byte[] bArr, byte[] bArr2) throws GeneralSecurityException {
  44.         Cipher instance = Cipher.getInstance("AES/CBC/PKCS7Padding");
  45.         instance.init(2, secretKeySpec, new IvParameterSpec(bArr));
  46.         byte[] doFinal = instance.doFinal(bArr2);
  47.         a("decryptedBytes", doFinal);
  48.         return doFinal;
  49.     }
  50.  
  51.     public static byte[] a(String str) throws GeneralSecurityException {
  52.         byte[] bArr = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  53.         byte[] bArr2 = null;
  54.         try {
  55.             SecretKeySpec b2 = b("%4#4&**@@@@%!!!".getBytes());
  56.             Cipher instance = Cipher.getInstance("AES/CBC/PKCS7Padding");
  57.             instance.init(1, b2, new IvParameterSpec(bArr));
  58.             bArr2 = instance.doFinal(str.getBytes("UTF-8"));
  59.             a("decryptedBytes", bArr2);
  60.             return bArr2;
  61.         } catch (UnsupportedEncodingException e2) {
  62.             e2.printStackTrace();
  63.             return bArr2;
  64.         }
  65.     }
  66.  
  67.     private static void a(String str, byte[] bArr) {
  68.         if (f4798b) {
  69.             StringBuilder sb = new StringBuilder();
  70.             sb.append(str);
  71.             sb.append("[");
  72.             sb.append(bArr.length);
  73.             sb.append("] [");
  74.             sb.append(a(bArr));
  75.             sb.append("]");
  76.             Log.d("AESCrypt", sb.toString());
  77.         }
  78.     }
  79.  
  80.     private static void a(String str, String str2) {
  81.         if (f4798b) {
  82.             StringBuilder sb = new StringBuilder();
  83.             sb.append(str);
  84.             sb.append("[");
  85.             sb.append(str2.length());
  86.             sb.append("] [");
  87.             sb.append(str2);
  88.             sb.append("]");
  89.             Log.d("AESCrypt", sb.toString());
  90.         }
  91.     }
  92.  
  93.     private static String a(byte[] bArr) {
  94.         char[] cArr = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
  95.         char[] cArr2 = new char[(bArr.length * 2)];
  96.         for (int i = 0; i < bArr.length; i++) {
  97.             byte b2 = bArr[i] & 255;
  98.             int i2 = i * 2;
  99.             cArr2[i2] = cArr[b2 >>> 4];
  100.             cArr2[i2 + 1] = cArr[b2 & 15];
  101.         }
  102.         return new String(cArr2);
  103.     }
  104. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×