Skip to content

Commit fd68f35

Browse files
authored
rsa_cipher.py: Use f-strings
1 parent f6d81d7 commit fd68f35

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

ciphers/rsa_cipher.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,9 @@ def encrypt_and_write_to_file(
7676
key_size, n, e = read_key_file(key_filename)
7777
if key_size < block_size * 8:
7878
sys.exit(
79-
"ERROR: Block size is {} bits and key size is {} bits. The RSA cipher "
80-
"requires the block size to be equal to or greater than the key size. "
81-
"Either decrease the block size or use different keys.".format(
82-
block_size * 8, key_size
83-
)
79+
f"ERROR: Block size is {block_size * 8} bits and key size is {key_size} "
80+
"bits. The RSA cipher requires the block size to be equal to or greater "
81+
"than the key size. Either decrease the block size or use different keys."
8482
)
8583

8684
encrypted_blocks = [str(i) for i in encrypt_message(message, (n, e), block_size)]
@@ -102,11 +100,9 @@ def read_from_file_and_decrypt(message_filename: str, key_filename: str) -> str:
102100

103101
if key_size < block_size * 8:
104102
sys.exit(
105-
"ERROR: Block size is {} bits and key size is {} bits. The RSA cipher "
106-
"requires the block size to be equal to or greater than the key size. "
107-
"Did you specify the correct key file and encrypted file?".format(
108-
block_size * 8, key_size
109-
)
103+
f"ERROR: Block size is {block_size * 8} bits and key size is {key_size} "
104+
"bits. The RSA cipher requires the block size to be equal to or greater "
105+
"than the key size. Were the correct key file and encrypted file specified?"
110106
)
111107

112108
encrypted_blocks = []

0 commit comments

Comments
 (0)