psf/black code formatting (#1421)
* added sol3.py for problem_20 * added sol4.py for problem_06 * ran `black .` on `\Python`
This commit is contained in:
committed by
Christian Clauss
parent
11e2207182
commit
7592cba417
@@ -1,5 +1,5 @@
|
||||
def encrypt(input_string: str, key: int) -> str:
|
||||
result = ''
|
||||
result = ""
|
||||
for x in input_string:
|
||||
if not x.isalpha():
|
||||
result += x
|
||||
@@ -11,7 +11,7 @@ def encrypt(input_string: str, key: int) -> str:
|
||||
|
||||
|
||||
def decrypt(input_string: str, key: int) -> str:
|
||||
result = ''
|
||||
result = ""
|
||||
for x in input_string:
|
||||
if not x.isalpha():
|
||||
result += x
|
||||
@@ -24,15 +24,15 @@ def decrypt(input_string: str, key: int) -> str:
|
||||
|
||||
def brute_force(input_string: str) -> None:
|
||||
key = 1
|
||||
result = ''
|
||||
result = ""
|
||||
while key <= 94:
|
||||
for x in input_string:
|
||||
indx = (ord(x) - key) % 256
|
||||
if indx < 32:
|
||||
indx = indx + 95
|
||||
result = result + chr(indx)
|
||||
print(f'Key: {key}\t| Message: {result}')
|
||||
result = ''
|
||||
print(f"Key: {key}\t| Message: {result}")
|
||||
result = ""
|
||||
key += 1
|
||||
return None
|
||||
|
||||
@@ -40,7 +40,7 @@ def brute_force(input_string: str) -> None:
|
||||
def main():
|
||||
while True:
|
||||
print(f'{"-" * 10}\n Menu\n{"-", * 10}')
|
||||
print(*["1.Encrpyt", "2.Decrypt", "3.BruteForce", "4.Quit"], sep='\n')
|
||||
print(*["1.Encrpyt", "2.Decrypt", "3.BruteForce", "4.Quit"], sep="\n")
|
||||
choice = input("What would you like to do?: ")
|
||||
if choice not in ["1", "2", "3", "4"]:
|
||||
print("Invalid choice, please enter a valid choice")
|
||||
|
||||
Reference in New Issue
Block a user