Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static byte[] encrypt(final byte[] key, final byte[] iv, final byte[] cleartext) throws Exception {
- /* perform AES-128 encryption */
- final Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
- cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "AES"),
- new IvParameterSpec(iv));
- Arrays.fill(key, (byte) 0x00);
- Arrays.fill(iv, (byte) 0x00);
- return cipher.doFinal(cleartext);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement