7
7
import javax .crypto .spec .GCMParameterSpec ;
8
8
import javax .crypto .spec .IvParameterSpec ;
9
9
import javax .crypto .spec .SecretKeySpec ;
10
- import java .nio .charset .Charset ;
11
10
import java .security .InvalidAlgorithmParameterException ;
12
11
import java .security .InvalidKeyException ;
13
12
import java .security .NoSuchAlgorithmException ;
14
13
import java .security .spec .AlgorithmParameterSpec ;
15
14
16
15
class AESCipher {
17
- private static final Charset charset = Charset .forName ("UTF-8" );
18
16
private final SecretKeySpec secretKey ;
19
17
private final AlgorithmParameterSpec ivSpec ;
20
18
private final AESAlgorithm algorithm ;
@@ -35,14 +33,14 @@ class AESCipher {
35
33
36
34
String encrypt (String plainText ) throws NoSuchPaddingException , NoSuchAlgorithmException , InvalidAlgorithmParameterException , InvalidKeyException , IllegalBlockSizeException , BadPaddingException {
37
35
Cipher cipher = getCipher (Cipher .ENCRYPT_MODE );
38
- byte [] cipherText = cipher .doFinal (plainText .getBytes (charset ));
36
+ byte [] cipherText = cipher .doFinal (plainText .getBytes (Constants . charset ));
39
37
return Base64Utils .encodeToString (cipherText );
40
38
}
41
39
42
40
String decrypt (String encryptedText ) throws NoSuchPaddingException , NoSuchAlgorithmException , InvalidAlgorithmParameterException , InvalidKeyException , IllegalBlockSizeException , BadPaddingException {
43
41
Cipher cipher = getCipher (Cipher .DECRYPT_MODE );
44
42
byte [] cipherText = cipher .doFinal (Base64Utils .decode (encryptedText ));
45
- return new String (cipherText , charset );
43
+ return new String (cipherText , Constants . charset );
46
44
}
47
45
48
46
private Cipher getCipher (int opMode ) throws NoSuchPaddingException , NoSuchAlgorithmException , InvalidAlgorithmParameterException , InvalidKeyException {
0 commit comments