这是某应用给的 Java 的解密算法
import org.apache.commons.codec.binary.Base64;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
public class AESUtils {
public static String aesDecrypt(String str, String key) throws Exception {
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "AES"));
byte[] bytes = Base64.decodeBase64(str);
bytes = cipher.doFinal(bytes);
return new String(bytes, StandardCharsets.UTF_8);
}
}
我尝试了多种,都无法解出来
参考加密数据(解密秘钥 1234567890123456 )
E4M54v2CbwnbdG+quqWwgFGI5dgx3shx2gGZRiihvkQQLgbH12Y9/dJXO1/7H7QLL3H9fstismlYMLQrZxShEyknFJcLG96HbG4Cx/7gq4YMXgZJDI9Qvm1sH6H4arIHaPTSbHTk
faYo7fo6Sc3lwBMOpJHi33Os5u7DobPmqkzkuyoRxbTD4mZaSYleDcYuouQTdma+rubH5PPzg0+R09XsEHWkgF6cc+Ylh2w0N6590eJDNdQvoI4m7eSiWQCJo5nN5zXj/2QeQcYwIfdpmQ==
应得到的解密数据(解密秘钥 1234567890123456 )
{
"id": "dbe8970a-53a7-165c-7339-02c55bbddea5",
"appKey": "FQa4kEGD",
"appId": "34526534673",
"msgType": "notice",
"time": "1603698652093",
"bizContent": {
"name:": "测试",
"value": "测试"
}
}
无奈不大懂 java ,需要用 PHP 来进行解密
求双修人士改为 PHP 可以用版本,谢!
1
y830CAa5nink4rUQ 2022-06-23 22:38:06 +08:00 1
50 块钱解君愁
|
2
leadfast 2022-06-23 22:38:54 +08:00 1
随便搜的一个就可以的啊
``` function decrypt($str, $key) { $decrypted = openssl_decrypt($str, 'AES-128-ECB', $key, OPENSSL_ZERO_PADDING); $dec_s = strlen($decrypted); $padding = ord($decrypted[$dec_s - 1]); $decrypted = substr($decrypted, 0, -$padding); return $decrypted; } $str = "E4M54v2CbwnbdG+quqWwgFGI5dgx3shx2gGZRiihvkQQLgbH12Y9/dJXO1/7H7QLL3H9fstismlYMLQrZxShEyknFJcLG96HbG4Cx/7gq4YMXgZJDI9Qvm1sH6H4arIHaPTSbHTkfaYo7fo6Sc3lwBMOpJHi33Os5u7DobPmqkzkuyoRxbTD4mZaSYleDcYuouQTdma+rubH5PPzg0+R09XsEHWkgF6cc+Ylh2w0N6590eJDNdQvoI4m7eSiWQCJo5nN5zXj/2QeQcYwIfdpmQ=="; $res = decrypt($str, "1234567890123456"); ``` |
3
y830CAa5nink4rUQ 2022-06-23 22:44:35 +08:00 1
openssl_decrypt(base64_decode('E4M54v2CbwnbdG+quqWwgFGI5dgx3shx2gGZRiihvkQQLgbH12Y9/dJXO1/7H7QLL3H9fstismlYMLQrZxShEyknFJcLG96HbG4Cx/7gq4YMXgZJDI9Qvm1sH6H4arIHaPTSbHTkfaYo7fo6Sc3lwBMOpJHi33Os5u7DobPmqkzkuyoRxbTD4mZaSYleDcYuouQTdma+rubH5PPzg0+R09XsEHWkgF6cc+Ylh2w0N6590eJDNdQvoI4m7eSiWQCJo5nN5zXj/2QeQcYwIfdpmQ=='), 'AES-128-ECB', '1234567890123456', OPENSSL_RAW_DATA);
``` { "id": "dbe8970a-53a7-165c-7339-02c55bbddea5", "appKey": "FQa4kEGD", "appId": "34526534673", "msgType": "notice", "time": "1603698652093", "bizContent": { "name:": "测试", "value": "测试" } } ``` |
4
holystrike OP 感谢楼上各佬,管用!
|