From d222291135ce2bc719caff1a370dcc4eb2b50603 Mon Sep 17 00:00:00 2001 From: wwwwwwwww <526125649@qq.com> Date: Mon, 15 Jun 2026 10:19:24 +0800 Subject: [PATCH] 1 --- video-gen-api/app/api/v1/payments.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/video-gen-api/app/api/v1/payments.py b/video-gen-api/app/api/v1/payments.py index a94bd1c3..58b384ae 100644 --- a/video-gen-api/app/api/v1/payments.py +++ b/video-gen-api/app/api/v1/payments.py @@ -167,11 +167,14 @@ async def wechat_callback(request: Request, db: AsyncSession = Depends(get_db)): # 使用 AES-GCM 解密 try: - # API v3 key 和 nonce 需要转换为字节串 + # 所有参数都需要转换为字节串 api_v3_key_bytes = api_v3_key.encode('utf-8') - nonce_bytes = nonce_str.encode('utf-8') + ciphertext_bytes = ciphertext.encode('utf-8') if ciphertext 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) - decrypted_str = aesgcm.decrypt(ciphertext, associated_data, nonce_bytes) + decrypted_str = aesgcm.decrypt(ciphertext_bytes, associated_data_bytes, nonce_bytes) except InvalidTag: logger.error("WeChat callback decryption failed: Invalid tag") raise HTTPException(status_code=400, detail="数据解密失败")