Created
December 5, 2016 10:12
-
-
Save KravaDanil/8990c00549cfc7a207485945339dcbca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static byte[] encrypt(byte[] key, byte[] input) throws Exception { | |
SecretKeySpec skeySpec = new SecretKeySpec(key, "AES"); | |
Cipher cipher = Cipher.getInstance("AES"); | |
cipher.init(Cipher.ENCRYPT_MODE, skeySpec); | |
byte[] encrypted = cipher.doFinal(input); | |
return encrypted; | |
} | |
private static byte[] decrypt(byte[] key, byte[] encrypted) throws Exception { | |
SecretKeySpec skeySpec = new SecretKeySpec(key, "AES"); | |
Cipher cipher = Cipher.getInstance("AES"); | |
cipher.init(Cipher.DECRYPT_MODE, skeySpec); | |
byte[] decrypted = cipher.doFinal(encrypted); | |
return decrypted; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment