mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 01:09:40 +08:00
MAINT: Updated f-string method (#6230)
* MAINT: Used f-string method Updated the code with f-string methods wherever required for a better and cleaner understanding of the code. * Updated files with f-string method * Update rsa_key_generator.py * Update rsa_key_generator.py * Update elgamal_key_generator.py * Update lru_cache.py I don't think this change is efficient but it might tackle the error as the error was due to using long character lines. * Update lru_cache.py * Update lru_cache.py Co-authored-by: cyai <seriesscar@gmail.com> Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
@ -34,9 +34,7 @@ def generateKey(keySize: int) -> tuple[tuple[int, int], tuple[int, int]]:
|
||||
|
||||
|
||||
def makeKeyFiles(name: str, keySize: int) -> None:
|
||||
if os.path.exists("%s_pubkey.txt" % (name)) or os.path.exists(
|
||||
"%s_privkey.txt" % (name)
|
||||
):
|
||||
if os.path.exists(f"{name}_pubkey.txt") or os.path.exists(f"{name}_privkey.txt"):
|
||||
print("\nWARNING:")
|
||||
print(
|
||||
'"%s_pubkey.txt" or "%s_privkey.txt" already exists. \n'
|
||||
@ -46,12 +44,12 @@ def makeKeyFiles(name: str, keySize: int) -> None:
|
||||
sys.exit()
|
||||
|
||||
publicKey, privateKey = generateKey(keySize)
|
||||
print("\nWriting public key to file %s_pubkey.txt..." % name)
|
||||
with open("%s_pubkey.txt" % name, "w") as out_file:
|
||||
print(f"\nWriting public key to file {name}_pubkey.txt...")
|
||||
with open(f"{name}_pubkey.txt", "w") as out_file:
|
||||
out_file.write(f"{keySize},{publicKey[0]},{publicKey[1]}")
|
||||
|
||||
print("Writing private key to file %s_privkey.txt..." % name)
|
||||
with open("%s_privkey.txt" % name, "w") as out_file:
|
||||
print(f"Writing private key to file {name}_privkey.txt...")
|
||||
with open(f"{name}_privkey.txt", "w") as out_file:
|
||||
out_file.write(f"{keySize},{privateKey[0]},{privateKey[1]}")
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user