Skip to content

Commit b10fa3f

Browse files
committed
fix: resolve ruff lint check errors
1 parent da4cf5b commit b10fa3f

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

ciphers/rc4.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def ksa(key: bytes) -> list[int]:
3131
return s_box
3232

3333

34-
def prga(s_box: list[int]) -> Generator[int, None, None]:
34+
def prga(s_box: list[int]) -> Generator[int]:
3535
"""
3636
Pseudo-Random Generation Algorithm (PRGA)
3737
=========================================
@@ -140,7 +140,6 @@ 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-
144143
doctest.testmod()
145144
sys.exit(0)
146145

@@ -160,9 +159,7 @@ def decrypt(ciphertext: bytes, key: bytes) -> bytes:
160159
if not key_str:
161160
print("Key cannot be empty!")
162161
continue
163-
encrypted_bytes = encrypt(
164-
plain_str.encode("utf-8"), key_str.encode("utf-8")
165-
)
162+
encrypted_bytes = encrypt(plain_str.encode("utf-8"), key_str.encode("utf-8"))
166163
print(f"Ciphertext (Hex): {encrypted_bytes.hex()}")
167164
elif choice == "2":
168165
hex_str = input("Enter hex ciphertext to decrypt: ")
@@ -173,9 +170,10 @@ def decrypt(ciphertext: bytes, key: bytes) -> bytes:
173170
try:
174171
cipher_bytes = bytes.fromhex(hex_str)
175172
decrypted_bytes = decrypt(cipher_bytes, key_str.encode("utf-8"))
176-
print(
177-
f"Decrypted text: {decrypted_bytes.decode('utf-8', errors='replace')}"
173+
decrypted_text = decrypted_bytes.decode(
174+
"utf-8", errors="replace"
178175
)
176+
print(f"Decrypted text: {decrypted_text}")
179177
except ValueError as e:
180178
print(f"Invalid input: {e}")
181179
else:

0 commit comments

Comments
 (0)