-
-
Save vivekgidmare/396cd43cc4a7e7a587c1ea9a09f01d48 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