gpt4 book ai didi

java - 如何解密 HttpsURLConnection

转载 作者:行者123 更新时间:2023-11-29 05:14:40 25 4
gpt4 key购买 nike

我的代码向网站发出 POST 请求,但响应看起来像是加密的,带有奇怪的字符。当我将我的应用配置为使用 fiddler 代理时,响应有效。我怎样才能让我的应用解密这个响应?

public class Login {
public Login() throws Exception {
URL url = new URL("https://account.leagueoflegends.com/auth");
HttpsURLConnection conn = (HttpsURLConnection)url.openConnection();
conn.setDoInput(true);
conn.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.111 Safari/537.36");
conn.addRequestProperty("Cookie", "xxx");
conn.addRequestProperty("Content-Length", "406");
conn.addRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
conn.addRequestProperty("Accept-Encoding", "gzip,deflate");
conn.addRequestProperty("Connection", "keep-alive");
conn.addRequestProperty("Referer", "xxx");
conn.setDoOutput(true);

OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());

writer.write("xxx");
writer.flush();
String line;
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
writer.close();
reader.close();

最佳答案

您明确请求压缩流:

conn.addRequestProperty("Accept-Encoding", "gzip,deflate");

删除该行以删除压缩。幸运的是,压缩不同于加密,它不需要您提供 key 。

关于java - 如何解密 HttpsURLConnection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27011874/

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