Skip to content

Commit 098dd1e

Browse files
kaiferroot
authored and
root
committed
RELEASE
1 parent 18e5e90 commit 098dd1e

File tree

6 files changed

+14
-9
lines changed

6 files changed

+14
-9
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ JAVA 1.8버전 사용자들을 위한 세션키 발급 및 개인정보 암복
66

77
예시)
88
```
9-
<version>0.0.7</version>
9+
<version>0.0.8</version>
1010
```
1111

1212
pom.xml 을 사용하시면 아래와 같이 추가해주세요.

src/main/java/im/toss/cert/sdk/AESCipher.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@
77
import javax.crypto.spec.GCMParameterSpec;
88
import javax.crypto.spec.IvParameterSpec;
99
import javax.crypto.spec.SecretKeySpec;
10-
import java.nio.charset.Charset;
1110
import java.security.InvalidAlgorithmParameterException;
1211
import java.security.InvalidKeyException;
1312
import java.security.NoSuchAlgorithmException;
1413
import java.security.spec.AlgorithmParameterSpec;
1514

1615
class AESCipher {
17-
private static final Charset charset = Charset.forName("UTF-8");
1816
private final SecretKeySpec secretKey;
1917
private final AlgorithmParameterSpec ivSpec;
2018
private final AESAlgorithm algorithm;
@@ -35,14 +33,14 @@ class AESCipher {
3533

3634
String encrypt(String plainText) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
3735
Cipher cipher = getCipher(Cipher.ENCRYPT_MODE);
38-
byte[] cipherText = cipher.doFinal(plainText.getBytes(charset));
36+
byte[] cipherText = cipher.doFinal(plainText.getBytes(Constants.charset));
3937
return Base64Utils.encodeToString(cipherText);
4038
}
4139

4240
String decrypt(String encryptedText) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException, IllegalBlockSizeException, BadPaddingException {
4341
Cipher cipher = getCipher(Cipher.DECRYPT_MODE);
4442
byte[] cipherText = cipher.doFinal(Base64Utils.decode(encryptedText));
45-
return new String(cipherText, charset);
43+
return new String(cipherText, Constants.charset);
4644
}
4745

4846
private Cipher getCipher(int opMode) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidAlgorithmParameterException, InvalidKeyException {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package im.toss.cert.sdk;
2+
3+
import java.nio.charset.Charset;
4+
5+
public class Constants {
6+
static final Charset charset = Charset.forName("UTF-8");
7+
}

src/main/java/im/toss/cert/sdk/HMAC.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ class HMAC {
1010

1111
static String calculateHash(String secret, String message) throws NoSuchAlgorithmException, InvalidKeyException {
1212
Mac sha256Hmac = Mac.getInstance(algorithm);
13-
SecretKeySpec secretKey = new SecretKeySpec(secret.getBytes(), algorithm);
13+
SecretKeySpec secretKey = new SecretKeySpec(secret.getBytes(Constants.charset), algorithm);
1414
sha256Hmac.init(secretKey);
15-
return bytesToHex(sha256Hmac.doFinal(message.getBytes()));
15+
return bytesToHex(sha256Hmac.doFinal(message.getBytes(Constants.charset)));
1616
}
1717

1818
private static final char[] HEX_ARRAY = "0123456789abcdef".toCharArray();

src/main/java/im/toss/cert/sdk/RSACipher.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ String encrypt(String plainText)
3131
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding");
3232
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
3333

34-
byte[] bytePlain = cipher.doFinal(plainText.getBytes());
34+
byte[] bytePlain = cipher.doFinal(plainText.getBytes(Constants.charset));
3535
return Base64Utils.encodeToString(bytePlain);
3636
}
3737
}

src/main/java/im/toss/cert/sdk/TossCertSessionGenerator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import java.util.UUID;
99

1010
public class TossCertSessionGenerator {
11-
private final static String version = "v1_0.0.7";
11+
private final static String version = "v1_0.0.8";
1212
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==";
1313

1414
private final RSACipher rsaCipher;

0 commit comments

Comments
 (0)