Skip to content

Commit

Permalink
RELEASE
Browse files Browse the repository at this point in the history
  • Loading branch information
kaifer authored and root committed Aug 31, 2022
1 parent 18e5e90 commit 098dd1e
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ JAVA 1.8버전 사용자들을 위한 세션키 발급 및 개인정보 암복

예시)
```
<version>0.0.7</version>
<version>0.0.8</version>
```

pom.xml 을 사용하시면 아래와 같이 추가해주세요.
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/im/toss/cert/sdk/AESCipher.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/im/toss/cert/sdk/Constants.java
Original file line number Diff line number Diff line change
@@ -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");
}
4 changes: 2 additions & 2 deletions src/main/java/im/toss/cert/sdk/HMAC.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/im/toss/cert/sdk/RSACipher.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 098dd1e

Please sign in to comment.