This repository has been archived on 2026-10-02. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
NeteaseUrl/music_api
snowy-yang d600b6a630 refactor: crypto 改用手写轮子的标准替代,去掉重复的函数内 import
- hex_digest:`"".join([hex(d)[2:].zfill(2) for d in data])` → `data.hex()`。
  前者每字节做一次 hex()+zfill 再拼接,后者是 C 实现;两者输出相同。
- hash_hex_digest:绕道 digest() → hex_digest() 两步,直接 hexdigest()。
- _aes_encrypt / encrypt 里的函数内 import 删除:模块顶部已导入
  Cipher/algorithms/modes/padding,函数内又导一遍纯属冗余;
  base64、secrets 则提到模块顶部(原来每次调用都要走一次 import 查找)。
- PKCS7(128) 保留字面量并加注释:**不要**改写成 algorithms.AES.block_size
  ——它在类型存根里声明为 property 而非 int,pyright 会报 reportArgumentType
  (本次实测踩到,门禁拦下)。

等价性验证:encrypt_params 对固定 payload 的输出 sha1 保持
76e3738f8eab61fcfd1145164ba8e1f91d40ee4f 不变;hex_digest/hash_hex_digest
的输出逐字符相同;并做了 docstring 逐条比对确认无文本误伤。
2026-09-26 14:16:05 +08:00
..