sha256 속도빠른 암호화, 복호화 처리 추가
parent
53839ddb2b
commit
6039f04bcb
|
|
@ -22,7 +22,29 @@ import javax.crypto.spec.IvParameterSpec;
|
|||
import javax.crypto.spec.PBEKeySpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import egovframework.com.cmm.service.EgovProperties;
|
||||
|
||||
public class CryptoUtil {
|
||||
// ===== [고정 키 AES - 빠른 버전] =====
|
||||
private static SecretKeySpec FIXED_SECRET_KEY;
|
||||
|
||||
/**
|
||||
* encryptQuickAES key
|
||||
* 서버 기동시 1회 자동 실행됨
|
||||
*/
|
||||
static {
|
||||
try {
|
||||
String key = EgovProperties.getProperty("SHA256.secret_key").trim();
|
||||
|
||||
MessageDigest sha = MessageDigest.getInstance("SHA-256");
|
||||
byte[] keyBytes = sha.digest(key.getBytes("UTF-8"));
|
||||
|
||||
FIXED_SECRET_KEY = new SecretKeySpec(keyBytes, "AES");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("CryptoUtil AES key initialization failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* MD5 로 해시 한다.
|
||||
*
|
||||
|
|
@ -142,4 +164,27 @@ public class CryptoUtil {
|
|||
byte[] decryptedTextBytes = cipher.doFinal(encryoptedTextBytes);
|
||||
return new String(decryptedTextBytes);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* AES 고정 키 암호화 (빠름)
|
||||
*/
|
||||
public static String encryptQuickAES(String plainText) throws Exception {
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, FIXED_SECRET_KEY);
|
||||
return Base64.getEncoder()
|
||||
.encodeToString(cipher.doFinal(plainText.getBytes("UTF-8")));
|
||||
}
|
||||
|
||||
/**
|
||||
* AES 고정 키 복호화
|
||||
*/
|
||||
public static String decryptQuickAES(String cipherText) throws Exception {
|
||||
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
|
||||
cipher.init(Cipher.DECRYPT_MODE, FIXED_SECRET_KEY);
|
||||
return new String(
|
||||
cipher.doFinal(Base64.getDecoder().decode(cipherText)),
|
||||
"UTF-8"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,3 +38,8 @@ JWT.secret_key=RnrxhWlQksportalSystem!@!@$#@!@#@!$12442321
|
|||
JWT.access_expired=1800000
|
||||
O2MAP.wms.url=http://10.dbnt.co.kr:2936/o2map/services/wms
|
||||
LOCAL.wms.url=http://10.dbnt.co.kr:2936/o2map/services/wms
|
||||
|
||||
###############################################
|
||||
################### SHA256 #################
|
||||
###############################################
|
||||
SHA256.secret_key=RnrxhwlQksportalSystem!@34$%
|
||||
Loading…
Reference in New Issue