We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1, 在magic-api中使用AES加密功能, 代码如下 这是magic自带执行 , 本地java环境执行aes加密没问题
import cn.hutool.core.util.CharsetUtil; import cn.hutool.crypto.KeyUtil; import cn.hutool.crypto.SecureUtil; import cn.hutool.crypto.symmetric.SymmetricAlgorithm; import cn.hutool.crypto.symmetric.SymmetricCrypto; import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; import java.nio.charset.StandardCharsets; import java.util.Base64; import java.lang.String; Random random = new Random(); var randomNumber = random.nextInt(100); long startTime = System.currentTimeMillis(); try { //执行 Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding"); String content = "Hello World !"; String secretKey = "2023_10_21_23_00"; cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(secretKey.getBytes(), "AES")); byte encryptStr = cipher.doFinal(content.getBytes(StandardCharsets.UTF_8)); var s = Base64.getEncoder().encodeToString(encryptStr); //执行解密 byte encryptByte = Base64.getDecoder().decode(s); byte decryptBytes = cipher.doFinal(encryptByte); String s1 = new String(decryptBytes, "utf-8"); // string s1 = decryptBytes::string return s + " s1: " +s1 } catch (e){ return ""+e } return 'Hello: ' + s
2, 运行上述代码, api返回值如下
{ "code": 1, "message": "success", "data":"KyPPZortd3pLh9Cnkz+xtw== s1: �����>/D�T�q\\{˷W��l��uE���p��m", "timestamp": 1704275711438, "executeTime": 3 }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
🐛🐛BUG: AES解密的返回值乱码
问题描述
1, 在magic-api中使用AES加密功能, 代码如下
这是magic自带执行 , 本地java环境执行aes加密没问题
2, 运行上述代码, api返回值如下
二, 截图描述
The text was updated successfully, but these errors were encountered: