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 8ef3861 commit 95eb1e9Copy full SHA for 95eb1e9
crypto/ChaCha20.py
@@ -103,3 +103,19 @@ def _apply_keystream(self, data: bytes) -> bytes:
103
xor_block.append(input_byte ^ keystream_byte)
104
result += bytes(xor_block)
105
return result
106
+ def encrypt(self, plaintext: bytes) -> bytes:
107
+ """
108
+ Encrypts the given plaintext using the ChaCha20 stream cipher.
109
+
110
+ This method uses the ChaCha20 keystream generated from the
111
+ key, nonce, and counter to XOR with the plaintext, producing ciphertext.
112
113
+ Args:
114
+ plaintext (bytes): The plaintext data to be encrypted.
115
116
+ Returns:
117
+ bytes: The resulting ciphertext.
118
119
+ return self._apply_keystream(plaintext)
120
121
0 commit comments