def main(): #Parse parameters parser = argparse.ArgumentParser() parser.add_argument("-m", "--mode", dest="mode", default = "encrypt", help="Encrypt or Decrypt") parser.add_argument("-i", "--inputfile", dest="inputFile", help="Input Name") parser.add_argument("-o", "--outputfile", dest="outputFile", help="Output Name") parser.add_argument("-s", "--seed", dest="seed", help="Integer seed") args = parser.parse_args() #generating key from seed key = rv.keywordFromSeed(args.seed) #opening an input file with read mode input = open(args.inputFile, 'r') message = input.read() cipherText = "" plainText = "" if(args.mode == 'encrypt'): #encryption of input message cipherText = rv.encryption(message,key,args.seed) #writing to output file output = open(args.outputFile,'w') output.write(str(cipherText)) else: #decryption of input message plainText = rv.decryption(message,key,args.seed) #writing to output file output = open(args.outputFile,'w') output.write(str(plainText))
def main(): parser = argparse.ArgumentParser() parser.add_argument("-m", "--mode", dest="mode", default = "encrypt", help="Encrypt or Decrypt") parser.add_argument("-i", "--inputfile", dest="inputFile", default = "inputFile.txt", help="Input Name") parser.add_argument("-o", "--outputfile", dest="outputFile", default = "outputFile.txt", help="Output Name") parser.add_argument("-s", "--seed", dest="seed", default =14325107, help="Integer seed") args = parser.parse_args() seed = int(args.seed) f = open(args.inputFile,'r') message = f.read() keyWord=rv.keywordFromSeed(seed) rv.printMatrix() if(args.mode == 'encrypt'): data = rv.encryption(message,keyWord) o = open(args.outputFile,'w') o.write(data) else: data = rv.decryption(message,keyWord) o = open(args.outputFile,'w') o.write(data)
#adding parser arguments parser = argparse.ArgumentParser() parser.add_argument("-m", "--mode", dest="mode", default = "encrypt", help="Encrypt or Decrypt") parser.add_argument("-i", "--inputfile", dest="inputFile", help="Input Name") parser.add_argument("-o", "--outputfile", dest="outputFile", help="Output Name") parser.add_argument("-s", "--seed", dest="seed",help="Integer seed") args = parser.parse_args() #generating a keyword seed = args.seed f = open(args.inputFile,'r') message = f.read() #encrypting the plaintext if(args.mode == 'encrypt'): data = rv.encryption(message,int(seed),symbols) #decrypting the encoded message else: data = rv.decryption(message,int(seed),symbols) o = open(args.outputFile,'w') o.write(str(data)) o.close()