def main(): while True: print "Choose from job" print "1.Key Generation" print "2.Encrytion" print "3.Decryption" print "4.Exit" choice = sys.stdin.readline() if (choice == '1\n'): myKeyGenerator = keyGenerator() myKeyGenerator.keyGen() print "Key Generation Finished\n" elif (choice == '2\n'): encryptor = Encryption() encryptor.encrypt() print "Encryption Finished\n" elif (choice == '3\n'): decryptor = Decryption() decryptor.decrypt() print "Decryption Finished\n" elif (choice == '4\n'): break; else: print "invalid input" choice = sys.stdin.readline()
def main(self): responce = input( "If you want to encrypt a file type Y? If you want to input data to be encrypted type N. If you want to decrypt data type NN. Y/N/NN " ).upper().strip() while ((responce != "Y") and (responce != "N") and (responce != "NN")): print("\nResponce must be either Y/N/NN") responce = input( "If you want to encrypt a file type Y? If you want to input data to be encrypted type N. If you want to decrypt data type NN. Y/N/NN " ).upper().strip() if responce == "Y": # encrypt existing file filePath = self.__fileHandler() encryption = EncryptFile(filePath) encryption.encAlg(filePath, encryption.encFile()) responce = self.__responceHandler( "Do you want to delete the unencrypted file? Y/N (Y is recommended) " ) if responce == "Y": os.remove(os.path.join(self.__PATH, filePath)) elif responce == "NN": # decrypt an encrypted file filePath = self.__fileHandler() outName = input("Enter name of output file: ") while os.path.exists(outName): responce = self.__responceHandler( f"Are you sure you want to overwrite {outName}? Y/N ") if responce == "Y": break decrypt = Decryption() decrypt.decrypt(filePath, outName) responce = self.__responceHandler( "Do you want to delete the encrypted file Y/N ") if responce == "Y": os.remove(filePath) else: # encrypt user input data = input("Enter data to be encryped: ") encData = EncryptInput(data) encData.encAlg(outName=encData.encData()) os.remove(os.path.join(self.__PATH, "data.txt"))
message = raw_input("Enter your message: ") count = 0 count2 = 0 while len(message) == 0 and count2 != 1: if count2 == 1: print "Try again some other time." count2 += 1 message = raw_input("Enter some text for your message: ") print while encode.checkCharacters(message) and count2 < 1: if count == 1: print "There was a character in your message that is not supported.\nPlease try again later." break count += 1 print "Please enter only the following characters within your message:\nA-Z\n.\n?\n,\n:\nspace\n'\n_____________________________________________" message = raw_input("Re-enter your message: ") if count < 2 and count2 < 2: print "_____________________________________________\n\nEncryption Area: \n\n_____________________________________________\n" encryp.getMessage(message) encryp.generatingEncryptionCode(message) print "\n_____________________________________________\n\nDecryption Area: \n\n_____________________________________________\n" decrypt.getKey(encryp.getKeyEncode()) decrypt.getCode(encryp.getCode()) decryptedMessage = decrypt.decrypt()