package moa_simul; import java.util.Base64; import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; public class AES256 { private static SecretKeySpec getKeySpec(String encKey) { byte[] bytes = encKey.getBytes(); SecretKeySpec spec = new SecretKeySpec(bytes, "AES"); return spec; } public static String encrypt(String text, String encKey) throws Exception { SecretKeySpec spec = getKeySpec(encKey); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, spec); return Base64.getEncoder().encodeToString(cipher.doFinal(text.getBytes("UTF-8"))); } } package moa_simul; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; public class moa_simul { static DateTimeFormatter tidFormatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); public static void main(String[] args) throws Exception { String custNo = "704138"; String aesEncKey = "69f1c1e3d70c03ca58141c2b5769d385"; LocalDateTime now = LocalDateTime.now(); String trade_id = "TMOA"+now.format(tidFormatter); String user_key = "1217626"; String auth_trade_id = "TMOAA"+now.format(tidFormatter); String apply_point = "13000"; String enc_trade_id = AES256.encrypt(trade_id, aesEncKey); String enc_user_key = AES256.encrypt(user_key, aesEncKey); String enc_auth_trade_id = AES256.encrypt(auth_trade_id, aesEncKey); String enc_apply_point = AES256.encrypt(apply_point, aesEncKey); System.out.println("$.ajax({type:'POST',url:'/pay/tmoapoint/tmoaPointResInfo',"); System.out.println("contentType:'application/json',"); System.out.println("data:JSON.stringify({"); System.out.println("'cust_no':'704138',"); System.out.println("'etc1':'1217626',"); System.out.println("'trade_id':'"+enc_trade_id+"',"); System.out.println("'user_key':'"+enc_user_key+"',"); System.out.println("'auth_trade_id':'"+enc_auth_trade_id+"',"); System.out.println("'apply_point':'"+enc_apply_point+"',"); System.out.println("'return_code':'0000',"); System.out.println("'return_msg':'(현정)정상처리되었습니다'"); System.out.println("})});"); } }