|
| 1 | +from encrypt import encryption, decryption |
| 2 | +from json_convert import jsonToDict |
| 3 | +from utils import message |
| 4 | +from keys_init import get_filename_from_user, generate_encryption |
| 5 | +from menu_functions import add, subtract, modify |
| 6 | +from helpVersion import help, version |
| 7 | + |
| 8 | +def main_menu(): |
| 9 | + message.success("1)Type ""add"" to add a key to the existing API keys. \n Type ""sub"" to Subtract a key to the existing API keys. \n Type ""mod"" to modify your Api keys \n Type ""Encrypt"" to Encrypt your Keys \n Type ""Decrypt"" to decrypt your keys \n Type ""help""to get help\n Type ""version"" to know the current version") |
| 10 | + input= message.prompt("Enter your choice") |
| 11 | + filename= message.prompt("Enter file name") |
| 12 | + if(input=="add"): |
| 13 | + s= jsonToDict(filename) |
| 14 | + if(s == False): |
| 15 | + key1=message.prompt("enter the key") |
| 16 | + decryption(key1, filename) |
| 17 | + add(filename) |
| 18 | + encryption(key1, filename) |
| 19 | + else: |
| 20 | + add(filename) |
| 21 | + elif (input=="sub"): |
| 22 | + s= jsonToDict(filename) |
| 23 | + if(s == False): |
| 24 | + key1=message.prompt("enter the key") |
| 25 | + decryption(key1, filename) |
| 26 | + subtract(filename) |
| 27 | + encryption(key1, filename) |
| 28 | + else: |
| 29 | + subtract(filename) |
| 30 | + elif (input=="mod"): |
| 31 | + s= jsonToDict(filename) |
| 32 | + if(s == False): |
| 33 | + key1=message.prompt("enter the key") |
| 34 | + decryption(key1, filename) |
| 35 | + modify(filename) |
| 36 | + encryption(key1, filename) |
| 37 | + else: |
| 38 | + modify(filename) |
| 39 | + |
| 40 | + elif (input=="Encrypt"): |
| 41 | + s= jsonToDict(filename) |
| 42 | + |
| 43 | + if(s == False): |
| 44 | + message.success("The data is encrypted") |
| 45 | + else: |
| 46 | + key1=message.prompt("enter the key") |
| 47 | + message.success("The data was not encrypted") |
| 48 | + encryption(key1, filename) |
| 49 | + #print("The Json is now encrypted") |
| 50 | + |
| 51 | + elif (input=="Decrypt"): |
| 52 | + s= jsonToDict(filename) |
| 53 | + |
| 54 | + if(s == False): |
| 55 | + key1=message.prompt("enter the key") |
| 56 | + decryption(key1, filename) |
| 57 | + |
| 58 | + else: |
| 59 | + message.success("The data is not encrypted") |
| 60 | + elif(input=="help"): |
| 61 | + help() |
| 62 | + elif(input=="version"): |
| 63 | + version() |
| 64 | +main_menu() |
0 commit comments