diff --git a/jinrun/audit/审批接口.md b/jinrun/audit/审批接口.md index 8f610c8..310d12b 100644 --- a/jinrun/audit/审批接口.md +++ b/jinrun/audit/审批接口.md @@ -36,9 +36,8 @@ public static String getMD5Lower(String input) { 数据加密采用AES算法 加密模式: CBC 填充方式:PKCS5Padding -偏移量:iv(则一提供) 加密内容:data(加密数据) -密钥:appSecret(则一提供) +密钥:aesSecret(则一提供) 输出:base64 字符集:utf-8 注:无敏感数据则无需加密 @@ -46,13 +45,19 @@ public static String getMD5Lower(String input) { ### 数据加密示例 ```java -public static String aesEncrypt(String source, String secret) { +public static String encrypt(String plaintext, String aesSecret) { + byte[] keyBytes = Base64.getDecoder().decode(keyBase64); + SecretKeySpec secretKey = new SecretKeySpec(keyBytes, "AES"); + byte[] iv = new byte[16]; + SecureRandom secureRandom = new SecureRandom(); + secureRandom.nextBytes(iv); + IvParameterSpec ivParam = new IvParameterSpec(iv); Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding"); - SecretKeySpec keySpec = new SecretKeySpec(secret.getBytes(), "AES"); - IvParameterSpec ivSpec = new IvParameterSpec(IV_BYTES); - byte[] byteContent = source.getBytes("UTF-8"); - cipher.init(1, keySpec, ivSpec); - byte[] result = cipher.doFinal(byteContent); + cipher.init(1, secretKey, ivParam); + byte[] ciphertext = cipher.doFinal(plaintext.getBytes(StandardCharsets.UTF_8)); + byte[] result = new byte[16 + ciphertext.length]; + System.arraycopy(iv, 0, result, 0, 16); + System.arraycopy(ciphertext, 0, result, 16, ciphertext.length); return Base64.getEncoder().encodeToString(result); } ``` @@ -155,12 +160,13 @@ public static String aesEncrypt(String source, String secret) { #### 请求示例Java-SDK方式 -##### [下载SDK](https://zeyi-tms-product.oss-cn-hangzhou.aliyuncs.com/file/jar/java-sdk/zy-java-sdk-1.0.0.jar) +##### [下载SDK](https://zeyi-tms-product.oss-cn-hangzhou.aliyuncs.com/file/jar/java-sdk/zy-java-sdk-2.0.0.jar) ```java public static void main(String[] args) { String appKey = "bd95591ce63f4a78a54658c2d8ad5ff6"; String appSecret = "734a18117f614e60859efb8eea27c680"; + String aesSecret = "wJ3472SLpkZLnjtwMArhRg=="; ZYClient ZYClient = new ZYClient(appKey, appSecret); String data = "{\n" + " \"code\": \"JR202510200000003\",\n" + @@ -190,7 +196,7 @@ public static void main(String[] args) { " }\n" + " ]\n" + "}"; - HttpResponseData httpResponseData = ZYClient.doPost(Constants.TEST_HOST + "/tms-service-api/audit/send", AesUtils.aesEncrypt(data, appSecret)); + HttpResponseData httpResponseData = ZYClient.doPost(Constants.TEST_HOST + "/tms-service-api/audit/send", AesUtils.aesEncrypt(data, aesSecret)); } ``` @@ -276,12 +282,13 @@ public static void main(String[] args) { #### 请求示例Java-SDK方式 -##### [下载SDK](https://zeyi-tms-product.oss-cn-hangzhou.aliyuncs.com/file/jar/java-sdk/zy-java-sdk-1.0.0.jar) +##### [下载SDK](https://zeyi-tms-product.oss-cn-hangzhou.aliyuncs.com/file/jar/java-sdk/zy-java-sdk-2.0.0.jar) ```java public static void main(String[] args) { String appKey = "bd95591ce63f4a78a54658c2d8ad5ff6"; String appSecret = "734a18117f614e60859efb8eea27c680"; + String aesSecret = "wJ3472SLpkZLnjtwMArhRg=="; ZYClient ZYClient = new ZYClient(appKey, appSecret); String data = "{\n" + " \"code\": \"JR202510200000002\",\n" + @@ -290,7 +297,7 @@ public static void main(String[] args) { " \"remark\": \"付款金额错误, 撤销重新提交\",\n" + " \"username\": \"001073\"\n" + "}"; - HttpResponseData httpResponseData = ZYClient.doPost(Constants.TEST_HOST + "/tms-service-api/audit/cancel", AesUtils.aesEncrypt(data, appSecret)); + HttpResponseData httpResponseData = ZYClient.doPost(Constants.TEST_HOST + "/tms-service-api/audit/cancel", AesUtils.aesEncrypt(data, aesSecret)); } ``` @@ -378,7 +385,7 @@ public static void main(String[] args) { ### 则一Java-sdk -##### [下载Java-sdk](https://zeyi-tms-product.oss-cn-hangzhou.aliyuncs.com/file/jar/java-sdk/zy-java-sdk-1.0.0.jar) +##### [下载Java-sdk](https://zeyi-tms-product.oss-cn-hangzhou.aliyuncs.com/file/jar/java-sdk/zy-java-sdk-2.0.0.jar) ## 更新日志 -- libgit2 0.21.0