Skip to content

Commit a810635

Browse files
committed
Merge branch 'add-rc4' of https://github.com/harrish243/Python into add-rc4
2 parents dcae768 + 02bd327 commit a810635

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

ciphers/rc4.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ def decrypt(ciphertext: bytes, key: bytes) -> bytes:
176176
# Check for doctests
177177
if len(sys.argv) > 1 and sys.argv[1] == "--test":
178178
import doctest
179+
179180
doctest.testmod()
180181
sys.exit(0)
181182

@@ -195,7 +196,9 @@ def decrypt(ciphertext: bytes, key: bytes) -> bytes:
195196
if not key_str:
196197
print("Key cannot be empty!")
197198
continue
198-
encrypted_bytes = encrypt(plain_str.encode("utf-8"), key_str.encode("utf-8"))
199+
encrypted_bytes = encrypt(
200+
plain_str.encode("utf-8"), key_str.encode("utf-8")
201+
)
199202
print(f"Ciphertext (Hex): {encrypted_bytes.hex()}")
200203
elif choice == "2":
201204
hex_str = input("Enter hex ciphertext to decrypt: ")
@@ -206,9 +209,7 @@ def decrypt(ciphertext: bytes, key: bytes) -> bytes:
206209
try:
207210
cipher_bytes = bytes.fromhex(hex_str)
208211
decrypted_bytes = decrypt(cipher_bytes, key_str.encode("utf-8"))
209-
decrypted_text = decrypted_bytes.decode(
210-
"utf-8", errors="replace"
211-
)
212+
decrypted_text = decrypted_bytes.decode("utf-8", errors="replace")
212213
print(f"Decrypted text: {decrypted_text}")
213214
except ValueError as e:
214215
print(f"Invalid input: {e}")

0 commit comments

Comments
 (0)