mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
pyupgrade --py37-plus **/*.py (#1654)
* pyupgrade --py37-plus **/*.py * fixup! Format Python code with psf/black push
This commit is contained in:
committed by
John Law
parent
34c808b375
commit
28419cf839
@@ -40,7 +40,7 @@ def decrypt(message):
|
||||
translated = translated + LETTERS[num]
|
||||
else:
|
||||
translated = translated + symbol
|
||||
print("Decryption using Key #%s: %s" % (key, translated))
|
||||
print(f"Decryption using Key #{key}: {translated}")
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -78,7 +78,7 @@ class HillCipher:
|
||||
req_l = len(self.key_string)
|
||||
if gcd(det, len(self.key_string)) != 1:
|
||||
raise ValueError(
|
||||
"discriminant modular {0} of encryption key({1}) is not co prime w.r.t {2}.\nTry another key.".format(
|
||||
"discriminant modular {} of encryption key({}) is not co prime w.r.t {}.\nTry another key.".format(
|
||||
req_l, det, req_l
|
||||
)
|
||||
)
|
||||
|
||||
@@ -101,7 +101,7 @@ def encryptAndWriteToFile(
|
||||
for i in range(len(encryptedBlocks)):
|
||||
encryptedBlocks[i] = str(encryptedBlocks[i])
|
||||
encryptedContent = ",".join(encryptedBlocks)
|
||||
encryptedContent = "%s_%s_%s" % (len(message), blockSize, encryptedContent)
|
||||
encryptedContent = "{}_{}_{}".format(len(message), blockSize, encryptedContent)
|
||||
with open(messageFilename, "w") as fo:
|
||||
fo.write(encryptedContent)
|
||||
return encryptedContent
|
||||
|
||||
@@ -43,11 +43,11 @@ def makeKeyFiles(name, keySize):
|
||||
publicKey, privateKey = generateKey(keySize)
|
||||
print("\nWriting public key to file %s_pubkey.txt..." % name)
|
||||
with open("%s_pubkey.txt" % name, "w") as fo:
|
||||
fo.write("%s,%s,%s" % (keySize, publicKey[0], publicKey[1]))
|
||||
fo.write("{},{},{}".format(keySize, publicKey[0], publicKey[1]))
|
||||
|
||||
print("Writing private key to file %s_privkey.txt..." % name)
|
||||
with open("%s_privkey.txt" % name, "w") as fo:
|
||||
fo.write("%s,%s,%s" % (keySize, privateKey[0], privateKey[1]))
|
||||
fo.write("{},{},{}".format(keySize, privateKey[0], privateKey[1]))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -2,7 +2,7 @@ import random
|
||||
import string
|
||||
|
||||
|
||||
class ShuffledShiftCipher(object):
|
||||
class ShuffledShiftCipher:
|
||||
"""
|
||||
This algorithm uses the Caesar Cipher algorithm but removes the option to
|
||||
use brute force to decrypt the message.
|
||||
|
||||
@@ -17,7 +17,7 @@ def main():
|
||||
mode = "decrypt"
|
||||
translated = decryptMessage(key, message)
|
||||
|
||||
print("\n%sion: \n%s" % (mode.title(), translated))
|
||||
print("\n{}ion: \n{}".format(mode.title(), translated))
|
||||
|
||||
|
||||
def checkValidKey(key):
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"""
|
||||
|
||||
|
||||
class XORCipher(object):
|
||||
class XORCipher:
|
||||
def __init__(self, key=0):
|
||||
"""
|
||||
simple constructor that receives a key or uses
|
||||
|
||||
Reference in New Issue
Block a user