Added Random key generation

This commit is contained in:
Willow Behar
2020-10-16 12:29:56 -05:00
parent 47363c3726
commit e0fc2358a0

View File

@ -5,6 +5,7 @@ Description: A Caesar Cipher coding challenge given by the Crunix Club"
""" """
import sys import sys
import random
help_text = """ help_text = """
NAME NAME
@ -26,6 +27,9 @@ help_text = """
""" """
def main(): def main():
#Help
if "-h" in sys.argv:
print(help_text)
#Get Key #Get Key
if "-k" in sys.argv: if "-k" in sys.argv:
#Find key flag location #Find key flag location
@ -33,12 +37,10 @@ def main():
#Get Key Integer #Get Key Integer
key = int(sys.argv[key_flag_location + 1]) key = int(sys.argv[key_flag_location + 1])
else: else:
print("Missing Key") #Randomly generate a key
print(help_text) key = random.randint(0, 100)
if "-h" in sys.argv: print("Key:", key)
#Help if "-E" in sys.argv:
print(help_text)
elif "-E" in sys.argv:
#Get Encrypt Flag Location #Get Encrypt Flag Location
encrypt_flag_location = sys.argv.index("-E") encrypt_flag_location = sys.argv.index("-E")
#Get String to encrypt #Get String to encrypt