[GH-ISSUE #225] iv 中包含 \r\n 导致 Decryption Failed #202

Closed
opened 2026-03-03 11:37:56 +03:00 by kerem · 1 comment
Owner

Originally created by @zhangyoufu on GitHub (Nov 30, 2023).
Original GitHub issue: https://github.com/Finb/Bark/issues/225

我使用下面的代码生成随机 iv,使用了很长时间后,遇到偶发的Decryption Failed报错。

iv = bytearray(Cryptodome.Random.get_random_bytes(16))
for i in range(len(iv)):
    iv[i] &= 0x7F # ensure ASCII
req_json['iv'] = iv.decode()

测试后发现,如果 iv 参数中存在 \r\n 会引起 Decryption Failed 错误。单独的 \r 或者 \n 都没有问题。

Originally created by @zhangyoufu on GitHub (Nov 30, 2023). Original GitHub issue: https://github.com/Finb/Bark/issues/225 我使用下面的代码生成随机 iv,使用了很长时间后,遇到偶发的`Decryption Failed`报错。 ```python iv = bytearray(Cryptodome.Random.get_random_bytes(16)) for i in range(len(iv)): iv[i] &= 0x7F # ensure ASCII req_json['iv'] = iv.decode() ``` 测试后发现,如果 iv 参数中存在 `\r\n` 会引起 `Decryption Failed` 错误。单独的 `\r` 或者 `\n` 都没有问题。
kerem closed this issue 2026-03-03 11:37:56 +03:00
Author
Owner

@Finb commented on GitHub (Sep 20, 2024):

是不是这个导致http报文换行了,建议生成端防止一下这种特殊字符

<!-- gh-comment-id:2363047528 --> @Finb commented on GitHub (Sep 20, 2024): 是不是这个导致http报文换行了,建议生成端防止一下这种特殊字符
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/Bark#202
No description provided.