sha256 속도빠른 암호화, 복호화 처리 추가

main
유지인 2026-01-20 14:45:22 +09:00
parent 53839ddb2b
commit 6039f04bcb
2 changed files with 51 additions and 1 deletions

View File

@ -22,7 +22,29 @@ import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec; import javax.crypto.spec.SecretKeySpec;
import egovframework.com.cmm.service.EgovProperties;
public class CryptoUtil { 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 . * MD5 .
* *
@ -142,4 +164,27 @@ public class CryptoUtil {
byte[] decryptedTextBytes = cipher.doFinal(encryoptedTextBytes); byte[] decryptedTextBytes = cipher.doFinal(encryoptedTextBytes);
return new String(decryptedTextBytes); 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"
);
}
} }

View File

@ -38,3 +38,8 @@ JWT.secret_key=RnrxhWlQksportalSystem!@!@$#@!@#@!$12442321
JWT.access_expired=1800000 JWT.access_expired=1800000
O2MAP.wms.url=http://10.dbnt.co.kr:2936/o2map/services/wms O2MAP.wms.url=http://10.dbnt.co.kr:2936/o2map/services/wms
LOCAL.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$%