thieumao

giai ma

Jan 15th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.84 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6.  
  7. package giaimathu;
  8. import java.security.NoSuchAlgorithmException;
  9. import javax.crypto.Cipher;
  10. import javax.crypto.NoSuchPaddingException;
  11. import javax.crypto.spec.IvParameterSpec;
  12. import javax.crypto.spec.SecretKeySpec;
  13.  
  14. public final class at {
  15.     private IvParameterSpec a = new IvParameterSpec(MyApplication.a.getBytes());
  16.     private SecretKeySpec b = new SecretKeySpec(MyApplication.b.getBytes(),
  17.             "AES");
  18.     private Cipher c;
  19.  
  20.     public at() {
  21.         try {
  22.             this.c = Cipher.getInstance("AES/CBC/NoPadding");
  23.             return;
  24.         } catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {
  25.             localNoSuchAlgorithmException.printStackTrace();
  26.             return;
  27.         } catch (NoSuchPaddingException localNoSuchPaddingException) {
  28.             localNoSuchPaddingException.printStackTrace();
  29.         }
  30.     }
  31.  
  32. //  private static byte[] b(String paramString) {
  33. //      byte[] arrayOfByte = null;
  34. //      if (paramString == null) {
  35. //          return null;
  36. //      } else {
  37. //          while (true) {
  38. //              int i = paramString.length();
  39. //              arrayOfByte = null;
  40. //              if (i < 2)
  41. //                  continue;
  42. //              int j = paramString.length() / 2;
  43. //              arrayOfByte = new byte[j];
  44. //              for (int k = 0; k < j; k++)
  45. //                  arrayOfByte[k] = (byte) Integer.parseInt(
  46. //                          paramString.substring(k * 2, 2 + k * 2), 16);
  47. //              return arrayOfByte;
  48. //          }
  49. //      }
  50. //  }
  51.  
  52.     public final byte[] a(String paramString) {
  53.         if ((paramString == null) || (paramString.length() == 0)) {
  54.             return null;
  55.         } else {
  56.             try {
  57.                 this.c.init(2, this.b, this.a);
  58.                 byte[] arrayOfByte = this.c.doFinal(HexToBytes.fromHexString(paramString));
  59.                 return arrayOfByte;
  60.             } catch (Exception localException) {
  61.                 return null;
  62.             }
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment