Skip to content

Commit 02bd327

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent b10fa3f commit 02bd327

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
@@ -140,6 +140,7 @@ def decrypt(ciphertext: bytes, key: bytes) -> bytes:
140140
# Check for doctests
141141
if len(sys.argv) > 1 and sys.argv[1] == "--test":
142142
import doctest
143+
143144
doctest.testmod()
144145
sys.exit(0)
145146

@@ -159,7 +160,9 @@ def decrypt(ciphertext: bytes, key: bytes) -> bytes:
159160
if not key_str:
160161
print("Key cannot be empty!")
161162
continue
162-
encrypted_bytes = encrypt(plain_str.encode("utf-8"), key_str.encode("utf-8"))
163+
encrypted_bytes = encrypt(
164+
plain_str.encode("utf-8"), key_str.encode("utf-8")
165+
)
163166
print(f"Ciphertext (Hex): {encrypted_bytes.hex()}")
164167
elif choice == "2":
165168
hex_str = input("Enter hex ciphertext to decrypt: ")
@@ -170,9 +173,7 @@ def decrypt(ciphertext: bytes, key: bytes) -> bytes:
170173
try:
171174
cipher_bytes = bytes.fromhex(hex_str)
172175
decrypted_bytes = decrypt(cipher_bytes, key_str.encode("utf-8"))
173-
decrypted_text = decrypted_bytes.decode(
174-
"utf-8", errors="replace"
175-
)
176+
decrypted_text = decrypted_bytes.decode("utf-8", errors="replace")
176177
print(f"Decrypted text: {decrypted_text}")
177178
except ValueError as e:
178179
print(f"Invalid input: {e}")

0 commit comments

Comments
 (0)