| 60 | } |
| 61 | |
| 62 | private String encrypt(String key, String input) throws Exception { |
| 63 | Cipher cipher = Cipher.getInstance(TRANSFORMATION); |
| 64 | SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), ALGORITHM); |
| 65 | cipher.init(Cipher.ENCRYPT_MODE, secretKey); |
| 66 | byte[] encryptedBytes = cipher.doFinal(input.getBytes()); |
| 67 | return Base64.getEncoder().encodeToString(encryptedBytes); |
| 68 | } |
| 69 | |
| 70 | private String decrypt(String key, String encryptedText) throws Exception { |
| 71 | Cipher cipher = Cipher.getInstance(TRANSFORMATION); |