diff --git a/README.md b/README.md
index 92e97cb..2fc051f 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@ JAVA 1.8버전 사용자들을 위한 세션키 발급 및 개인정보 암복
예시)
```
-0.0.7
+0.0.8
```
pom.xml 을 사용하시면 아래와 같이 추가해주세요.
diff --git a/src/main/java/im/toss/cert/sdk/AESCipher.java b/src/main/java/im/toss/cert/sdk/AESCipher.java
index 86b9110..53795e2 100644
--- a/src/main/java/im/toss/cert/sdk/AESCipher.java
+++ b/src/main/java/im/toss/cert/sdk/AESCipher.java
@@ -7,14 +7,12 @@
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
-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;
@@ -35,14 +33,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(charset));
+ byte[] cipherText = cipher.doFinal(plainText.getBytes(Constants.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, charset);
+ return new String(cipherText, Constants.charset);
}
private Cipher getCipher(int opMode) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException {
diff --git a/src/main/java/im/toss/cert/sdk/Constants.java b/src/main/java/im/toss/cert/sdk/Constants.java
new file mode 100644
index 0000000..d58eefa
--- /dev/null
+++ b/src/main/java/im/toss/cert/sdk/Constants.java
@@ -0,0 +1,7 @@
+package im.toss.cert.sdk;
+
+import java.nio.charset.Charset;
+
+public class Constants {
+ static final Charset charset = Charset.forName("UTF-8");
+}
diff --git a/src/main/java/im/toss/cert/sdk/HMAC.java b/src/main/java/im/toss/cert/sdk/HMAC.java
index 2c72944..9e31236 100644
--- a/src/main/java/im/toss/cert/sdk/HMAC.java
+++ b/src/main/java/im/toss/cert/sdk/HMAC.java
@@ -10,9 +10,9 @@ class HMAC {
static String calculateHash(String secret, String message) throws NoSuchAlgorithmException, InvalidKeyException {
Mac sha256Hmac = Mac.getInstance(algorithm);
- SecretKeySpec secretKey = new SecretKeySpec(secret.getBytes(), algorithm);
+ SecretKeySpec secretKey = new SecretKeySpec(secret.getBytes(Constants.charset), algorithm);
sha256Hmac.init(secretKey);
- return bytesToHex(sha256Hmac.doFinal(message.getBytes()));
+ return bytesToHex(sha256Hmac.doFinal(message.getBytes(Constants.charset)));
}
private static final char[] HEX_ARRAY = "0123456789abcdef".toCharArray();
diff --git a/src/main/java/im/toss/cert/sdk/RSACipher.java b/src/main/java/im/toss/cert/sdk/RSACipher.java
index c9664fe..8cdff28 100644
--- a/src/main/java/im/toss/cert/sdk/RSACipher.java
+++ b/src/main/java/im/toss/cert/sdk/RSACipher.java
@@ -31,7 +31,7 @@ String encrypt(String plainText)
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding");
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
- byte[] bytePlain = cipher.doFinal(plainText.getBytes());
+ byte[] bytePlain = cipher.doFinal(plainText.getBytes(Constants.charset));
return Base64Utils.encodeToString(bytePlain);
}
}
diff --git a/src/main/java/im/toss/cert/sdk/TossCertSessionGenerator.java b/src/main/java/im/toss/cert/sdk/TossCertSessionGenerator.java
index c083a74..54109aa 100644
--- a/src/main/java/im/toss/cert/sdk/TossCertSessionGenerator.java
+++ b/src/main/java/im/toss/cert/sdk/TossCertSessionGenerator.java
@@ -8,7 +8,7 @@
import java.util.UUID;
public class TossCertSessionGenerator {
- private final static String version = "v1_0.0.7";
+ private final static String version = "v1_0.0.8";
private final static String publicKey = "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAoVdxG0Qi9pip46Jw9ImSlPVD8+L2mM47ey6EZna7D7utgNdh8Tzkjrm1Yl4h6kPJrhdWvMIJGS51+6dh041IXcJEoUquNblUEqAUXBYwQM8PdfnS12SjlvZrP4q6whBE7IV1SEIBJP0gSK5/8Iu+uld2ctJiU4p8uswL2bCPGWdvVPltxAg6hfAG/ImRUKPRewQsFhkFvqIDCpO6aeaR10q6wwENZltlJeeRnl02VWSneRmPqqypqCxz0Y+yWCYtsA+ngfZmwRMaFkXcWjaWnvSqqV33OAsrQkvuBHWoEEkvQ0P08+h9Fy2+FhY9TeuukQ2CVFz5YyOhp25QtWyQI+IaDKk+hLxJ1APR0c3tmV0ANEIjO6HhJIdu2KQKtgFppvqSrZp2OKtI8EZgVbWuho50xvlaPGzWoMi9HSCb+8ARamlOpesxHH3O0cTRUnft2Zk1FHQb2Pidb2z5onMEnzP2xpTqAIVQyb6nMac9tof5NFxwR/c4pmci+1n8GFJIFN18j2XGad1mNyio/R8LabqnzNwJC6VPnZJz5/pDUIk9yKNOY0KJe64SRiL0a4SNMohtyj6QlA/3SGxaEXb8UHpophv4G9wN1CgfyUamsRqp8zo5qDxBvlaIlfkqJvYPkltj7/23FHDjPi8q8UkSiAeu7IV5FTfB5KsiN8+sGSMCAwEAAQ==";
private final RSACipher rsaCipher;