Skip to content

Commit

Permalink
ARC4.__init__() 不再允许使用空字节串作为密钥
Browse files Browse the repository at this point in the history
  • Loading branch information
nukemiko committed Nov 22, 2022
1 parent dfec557 commit 8619e11
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/libtakiyasha/stdciphers.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,13 @@ def __init__(self, key: BytesLike, /) -> None:
"""标准的 RC4 加密算法实现。
Args:
key: 密钥,长度不可大于 256
key: 密钥,长度不可大于 256,且不可为空
"""
key = tobytes(key)
self._key = key
key_len = len(key)
if key_len == 0:
raise ValueError(f"first argument 'key' cannot be an empty bytestring")
if key_len > 256:
raise ValueError(f'key length should be less than 256, got {key_len}')

Expand Down

0 comments on commit 8619e11

Please sign in to comment.