mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-12-04 02:23:59 +00:00
fix: match browser UTF-8 AES key bytes for auth params
This commit is contained in:
1 parent
76aaa7d214
commit
cc969bc79d
3 files changed
+38
-2
No files matched your search
@@ -7,6 +7,7 @@ import io.vertx.core.json.JsonObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
@@ -71,6 +72,11 @@ public class AuthParamCodec {
|
||||
}
|
||||
}
|
||||
|
||||
private static SecretKeySpec asAesKey(String key) {
|
||||
// Match CryptoJS: AES key lengths and values are defined by the full UTF-8 bytes.
|
||||
return new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "AES");
|
||||
}
|
||||
|
||||
public static String getEncryptKey() {
|
||||
return encryptKey;
|
||||
}
|
||||
@@ -112,7 +118,7 @@ public class AuthParamCodec {
|
||||
log.debug("Base64解码成功,长度: {}", base64Decoded.length);
|
||||
|
||||
// Step 3: AES解密
|
||||
String jsonStr = AESUtils.decryptByAES(base64Decoded, key);
|
||||
String jsonStr = AESUtils.decryptByAES(base64Decoded, asAesKey(key));
|
||||
|
||||
// Step 4: JSON解析
|
||||
JsonObject json = new JsonObject(jsonStr);
|
||||
@@ -156,7 +162,7 @@ public class AuthParamCodec {
|
||||
String jsonStr = authParam.toJsonObject().encode();
|
||||
|
||||
// Step 2: AES加密 + Base64编码
|
||||
String base64Encoded = AESUtils.encryptBase64ByAES(jsonStr, key);
|
||||
String base64Encoded = AESUtils.encryptBase64ByAES(jsonStr, asAesKey(key));
|
||||
|
||||
// Step 3: URL编码
|
||||
String urlEncoded = java.net.URLEncoder.encode(base64Encoded, StandardCharsets.UTF_8);
|
||||
|
||||
Reference in new issue
Block a user