gpt4 book ai didi

java - 客户端使用java解密

转载 作者:行者123 更新时间:2023-11-30 06:32:49 25 4
gpt4 key购买 nike

我在服务器端加密了 session ID,但是当我尝试在客户端解密 session ID 时,出现了一些错误。请任何人帮助解决该错误。

public static String decrypt(String sessionId)
{
try
{
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5PADDING");
final SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
cipher.init(Cipher.DECRYPT_MODE, secretKey);
final String decryptedSessionId = new String(cipher.doFinal(Base64.decodeBase64(sessionId)));
return decryptedSessionId;
}
catch (Exception e)
{
e.printStackTrace();

}
return null;
}

出现的错误是:JRE 模拟库中不存在类“javax.crypto.Cipher”,因此它不能在“某些”GWT 模块的客户端代码中使用。

此检查报告 JDK 类的客户端代码中的使用情况,而 JRE 模拟库中不存在该类。

我使用的加密方法是:

    public static String encrypt(String sessionId)
{
try
{
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
final SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
final String encryptedSessionId = Base64.encodeBase64String(cipher.doFinal(sessionId.getBytes()));
return encryptedSessionId;
}
catch (Exception e)
{
e.printStackTrace();
}
return null;

}

我是这方面的新手,请帮助我解决错误

最佳答案

嗯,您不能在客户端的 GWT 编码中使用 java 标准加密库。不支持。

使用gwt-crypto加密/解密必要的东西。

GWT-crypto 中的 GWT 客户端不支持 AES,但您可以使用 TripleDES。 TripleDES 也是非常安全的实现。

关于java - 客户端使用java解密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45737528/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com