ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 说明 虚拟卡券类商品下单,订单查询接口中的`cardNumber`、`cardPassword`、`cardLink`为AES加密数据,使用来访应用上的AppSecret进行加密,需解密为明文 ~~~json { "code": "0", "msg": "请求成功", "data": { "tradeNo": "c72264ac-Cf66-a2c1-DC75-FA3D28fE29C0", "dbyOrderId": "1411600301386975805440", "totalGoodsAmount": 2640, "totalFreightAmount": 0, "orderItems": [ { "orderItemId": "1600301440872611840", "orderType": "virtual", "goodsAmount": 2640, "freightAmount": 0, "status": 103, "skuInfos": [ { "skuCode": "20197729024", "skuName": "奈雪の茶30元代金券", "skuNum": 1, "unitPrice": 2640, "account": "15678999877", "couponInfo": { "cardType": 4, "cardNumber": null, "cardPassword": "I58alWnanbQrg5IzXVhFoA==", "cardLink": null, "cardCreateTime": "1670376632927", "effectiveTime": "1673020799000" } } ] } ], "orderRemark": null }, "msgId": "672bf8b3876b4ecb", "success": true } ~~~ ## [](https://duobaoyu.com.cn/documentcenter?onlyFlag=7a989c821f9dfdba9bfe4515687c91c2#%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE)基础数据 **仅限测试使用** * AppSecret:ne3ee8xg3hyx4af9smmupsi8ums4hovj * 加密前的卡密:123qweASD * 加密后的卡密:I58alWnanbQrg5IzXVhFoA== ### [](https://duobaoyu.com.cn/documentcenter?onlyFlag=7a989c821f9dfdba9bfe4515687c91c2#java%E7%89%88%E6%9C%AC)Java版本 AES解密如下: ~~~text //参数列表:参数一为需要解密的密文,参数二为解密key,使用AppSecret作为解密key String dataText = AesUtil.decrypt("I58alWnanbQrg5IzXVhFoA==", "ne3ee8xg3hyx4af9smmupsi8ums4hovj"); System.out.println("解密后的数据:" + dataText);//123qweASD ~~~ * * * ~~~java import javax.crypto.Cipher; import javax.crypto.spec.SecretKeySpec; import java.nio.charset.StandardCharsets; import java.util.Base64; /** * AES工具类 */ public class AesUtil { /** * 加密 * @param content 待加密的字符串 * @param key 秘钥 */ public static String encrypt(String content, String key) throws Exception{ Cipher cipher = Cipher.getInstance("AES"); SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "AES"); cipher.init(Cipher.ENCRYPT_MODE, keySpec); byte[] encodeBytes = Base64.getEncoder().encode(cipher.doFinal(content.getBytes(StandardCharsets.UTF_8))); return new String(encodeBytes, StandardCharsets.UTF_8); } /** * 解密 * @param content 待解密的字符串 * @param key 秘钥 */ public static String decrypt(String content, String key) throws Exception{ Cipher cipher = Cipher.getInstance("AES"); SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "AES"); cipher.init(Cipher.DECRYPT_MODE, keySpec); byte[] decodeBytes = cipher.doFinal(Base64.getDecoder().decode(content)); return new String(decodeBytes, StandardCharsets.UTF_8); } public static void main(String[] args) throws Exception { String appSecret = "ne3ee8xg3hyx4af9smmupsi8ums4hovj"; String contentStr = "123qweASD"; String encryptText = encrypt(contentStr, appSecret); System.out.println("加密后的字符串:" + encryptText); String decryptText = decrypt(encryptText, appSecret); System.out.println("解密后的字符串:" + decryptText); } } ~~~