mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-01-31 06:33:44 +00:00
Update caesar_cipher.py
Removed unnecessary recursion and updated code!
This commit is contained in:
parent
a84f7c073f
commit
4e0184a41d
|
@ -34,35 +34,30 @@ def brute_force(strng):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
while True:
|
||||||
print('-' * 10 + "\n**Menu**\n" + '-' * 10)
|
print('-' * 10 + "\n**Menu**\n" + '-' * 10)
|
||||||
print("1.Encrpyt")
|
print("1.Encrpyt")
|
||||||
print("2.Decrypt")
|
print("2.Decrypt")
|
||||||
print("3.BruteForce")
|
print("3.BruteForce")
|
||||||
print("4.Quit")
|
print("4.Quit")
|
||||||
while True:
|
|
||||||
choice = input("What would you like to do?: ")
|
choice = input("What would you like to do?: ")
|
||||||
if choice not in ['1', '2', '3', '4']:
|
if choice not in ['1', '2', '3', '4']:
|
||||||
print ("Invalid choice")
|
print ("Invalid choice")
|
||||||
elif choice == '1':
|
elif choice == '1':
|
||||||
strng = input("Please enter the string to be ecrypted: ")
|
strng = input("Please enter the string to be ecrypted: ")
|
||||||
while True:
|
|
||||||
key = int(input("Please enter off-set between 1-94: "))
|
key = int(input("Please enter off-set between 1-94: "))
|
||||||
if key in range(1, 95):
|
if key in range(1, 95):
|
||||||
print (encrypt(strng, key))
|
print (encrypt(strng.lower(), key))
|
||||||
main()
|
|
||||||
elif choice == '2':
|
elif choice == '2':
|
||||||
strng = input("Please enter the string to be decrypted: ")
|
strng = input("Please enter the string to be decrypted: ")
|
||||||
while True:
|
|
||||||
key = int(input("Please enter off-set between 1-94: "))
|
key = int(input("Please enter off-set between 1-94: "))
|
||||||
if key > 0 and key <= 94:
|
if key > 0 and key <= 94:
|
||||||
print(decrypt(strng, key))
|
print(decrypt(strng, key))
|
||||||
main()
|
|
||||||
elif choice == '3':
|
elif choice == '3':
|
||||||
strng = input("Please enter the string to be decrypted: ")
|
strng = input("Please enter the string to be decrypted: ")
|
||||||
brute_force(strng)
|
brute_force(strng)
|
||||||
main()
|
main()
|
||||||
elif choice == '4':
|
elif choice == '4':
|
||||||
print ("Goodbye.")
|
print ("Goodbye.")
|
||||||
sys.exit()
|
break
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user