We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3b20043 commit 4b663fbCopy full SHA for 4b663fb
crypto/ChaCha20.py
@@ -14,4 +14,14 @@ class ChaCha20:
14
12-byte (96-bit) nonce.
15
counter : int
16
32-bit counter, typically starts at 0.
17
- """
+ """
18
+ def __new__(cls, key: bytes, nonce: bytes, counter: int = 0):
19
+ if not isinstance(key, bytes) or len(key) != 32:
20
+ raise ValueError("Key must be exactly 32 bytes (256 bits).")
21
+ if not isinstance(nonce, bytes) or len(nonce) != 12:
22
+ raise ValueError("Nonce must be exactly 12 bytes (96 bits).")
23
+ instance = super().__new__(cls)
24
+ instance.key = key
25
+ instance.nonce = nonce
26
+ instance.counter = counter
27
+ return instance
0 commit comments