Advertisement
Guest User

Untitled

a guest
Jun 6th, 2013
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.41 KB | None | 0 0
  1.     public static byte[] encrypt(final byte[] key, final byte[] iv, final byte[] cleartext) throws Exception {
  2.         /* perform AES-128 encryption */
  3.         final Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
  4.  
  5.         cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"),
  6.                 new IvParameterSpec(iv));
  7.  
  8.         Arrays.fill(key, (byte) 0x00);
  9.         Arrays.fill(iv, (byte) 0x00);
  10.  
  11.         return cipher.doFinal(cleartext);
  12.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement