diff --git a/README.md b/README.md index 2ca1629..a399627 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ JAVA 1.8버전 사용자들을 위한 세션키 발급 및 개인정보 암복 예시) ``` -0.0.5 +0.0.6 ``` pom.xml 을 사용하시면 아래와 같이 추가해주세요. diff --git a/build.gradle b/build.gradle index a223508..4030ae7 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { } group 'com.github.toss' -version '0.0.5' +version '0.0.6' sourceCompatibility = JavaVersion.VERSION_1_6 targetCompatibility = JavaVersion.VERSION_1_6 diff --git a/src/main/java/im/toss/cert/sdk/AESCipher.java b/src/main/java/im/toss/cert/sdk/AESCipher.java index 03d8f08..86b9110 100644 --- a/src/main/java/im/toss/cert/sdk/AESCipher.java +++ b/src/main/java/im/toss/cert/sdk/AESCipher.java @@ -7,13 +7,14 @@ import javax.crypto.spec.GCMParameterSpec; import javax.crypto.spec.IvParameterSpec; import javax.crypto.spec.SecretKeySpec; -import java.nio.charset.StandardCharsets; +import java.nio.charset.Charset; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.spec.AlgorithmParameterSpec; class AESCipher { + private static final Charset charset = Charset.forName("UTF-8"); private final SecretKeySpec secretKey; private final AlgorithmParameterSpec ivSpec; private final AESAlgorithm algorithm; @@ -34,14 +35,14 @@ class AESCipher { String encrypt(String plainText) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { Cipher cipher = getCipher(Cipher.ENCRYPT_MODE); - byte[] cipherText = cipher.doFinal(plainText.getBytes(StandardCharsets.UTF_8)); + byte[] cipherText = cipher.doFinal(plainText.getBytes(charset)); return Base64Utils.encodeToString(cipherText); } String decrypt(String encryptedText) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException { Cipher cipher = getCipher(Cipher.DECRYPT_MODE); byte[] cipherText = cipher.doFinal(Base64Utils.decode(encryptedText)); - return new String(cipherText, StandardCharsets.UTF_8); + return new String(cipherText, charset); } private Cipher getCipher(int opMode) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException {