1
This commit is contained in:
@@ -167,11 +167,15 @@ async def wechat_callback(request: Request, db: AsyncSession = Depends(get_db)):
|
|||||||
|
|
||||||
# 使用 AES-GCM 解密
|
# 使用 AES-GCM 解密
|
||||||
try:
|
try:
|
||||||
# 所有参数都需要转换为字节串
|
# API v3 key 需要转换为字节串
|
||||||
api_v3_key_bytes = api_v3_key.encode('utf-8')
|
api_v3_key_bytes = api_v3_key.encode('utf-8')
|
||||||
ciphertext_bytes = ciphertext.encode('utf-8') if ciphertext else b''
|
|
||||||
|
# ciphertext 和 nonce 是 Base64 编码的,需要解码
|
||||||
|
ciphertext_bytes = b64decode(ciphertext) if ciphertext else b''
|
||||||
|
nonce_bytes = b64decode(nonce_str) if nonce_str else b''
|
||||||
|
|
||||||
|
# associated_data 是字符串,直接编码
|
||||||
associated_data_bytes = associated_data.encode('utf-8') if associated_data else b''
|
associated_data_bytes = associated_data.encode('utf-8') if associated_data else b''
|
||||||
nonce_bytes = nonce_str.encode('utf-8') if nonce_str else b''
|
|
||||||
|
|
||||||
aesgcm = AESGCM(api_v3_key_bytes)
|
aesgcm = AESGCM(api_v3_key_bytes)
|
||||||
decrypted_str = aesgcm.decrypt(ciphertext_bytes, associated_data_bytes, nonce_bytes)
|
decrypted_str = aesgcm.decrypt(ciphertext_bytes, associated_data_bytes, nonce_bytes)
|
||||||
|
|||||||
Reference in New Issue
Block a user