def main():
    parser = argparse.ArgumentParser()

#'''
#@Input example from my console:
#"python main.py -m decrypt -s 01020304 -i encryptedText.txt -o decryptedText.txt"
#"python main.py -m decrypt -s 01020304 -i encryptedText.txt -o decryptedText.txt"
#'''

    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",type=int)


    args = parser.parse_args()

    f = open(args.inputFile,'r')
    message = f.read()
    if(args.mode =='encrypt'):
        data = rv.encrypt(message,args.mode,args.seed)
    else:
        data = rv.decrypt(message,args.mode,args.seed)
    o = open(args.outputFile,'w')
    o.write(str(data))
Beispiel #2
0
def main():

	#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.encrypt(message,int(args.seed))
		o = open(args.outputFile,'w')
		o.write(str(data))
		o.close()
		#decrypting the encoded message
	else:
		data = rv.decrypt(message,int(args.seed))
		o = open(args.outputFile,'w')
		o.write(str(data))
		o.close()
def main():
    # Allows us to input command line arguements
    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()

    # Seeds the random number generator with the seed from the user.
    random.seed(args.seed)
    # Generates a keyword from the seed.
    keyword = rv.keywordFromSeed(args.seed)

    # Our "Alphabet"
    symbols = """ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~"""
    # Builds the Vigenere table
    vigenere = rv.buildVigenere(symbols)

    # Opens The input File
    f = open(args.inputFile, "r")
    # Reads the message from the input file for reading.
    message = f.read()

    # If the mode is encrypt, the message will be encrypted,
    # Else, it will be decrypted.
    if args.mode == "encrypt":
        data = rv.encrypt(vigenere, message, keyword)
    else:
        data = rv.decrypt(vigenere, message, keyword)
    # opens the output file for writing and writes the data to the file.
    o = open(args.outputFile, "w")
    o.write(str(data))
def main():
    #this code allows for command line argument parsing and program execution
    parser = argparse.ArgumentParser()

    parser.add_argument("-m", "--mode", dest = "mode", default = "encrypt", help = "Enter: encrypt or decrypt")
    parser.add_argument("-s", "--seed", dest = "seed", default = 77065084072073083070085078, help = "Enter an integer seed value")
    parser.add_argument("-i", "--inputfile", dest = "inputFile", help = "Enter the full input filename")
    parser.add_argument("-o", "--outputfile", dest = "outputFile", help = "Enter the full output filename")
    
    args = parser.parse_args()

    print ("Vigenère Encryption Tool")
    print ("Written By: Taylor Murphy")
    print ("********************************************************")
    
    #use given seed to seed the random number generator and find the keyword
    random.seed(args.seed)
    keyWord = rv.keywordFromSeed(args.seed)

    #read in the message or the cipher text from their respecive files    
    inp1 = open(args.inputFile,'r')
    message = inp1.read()
    
    inp2 = open(args.inputFile,'r')
    ctxt = inp2.read()
    
    print("Keyword:     ", keyWord)
    print("Message:     ", message)
    
    #encrypt or decrypt based on what was passed in via command line    
    if(args.mode == 'encrypt'):
        rv.encrypt(message, keyWord)    
    else:
        rv.decrypt(ctxt, keyWord)
    
    print ("Exiting Vigenère Encryption Tool, Goodbye")
    print ("********************************************************")
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", 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()
    seed = int(args.seed)
    f = open(args.inputFile,'r')
    message = f.read()
    if(args.mode == 'encrypt'):
        data = rv.encrypt(message,seed)
    else:
        data = rv.decrypt(message,seed)
    o = open(args.outputFile,'w')
    o.write(str(data))
def main():
    #The argparse module makes it easy to write user-friendly command-line interfaces
    parser = argparse.ArgumentParser()
    #Filling an ArgumentParser with information about program arguments is done by making calls to the add_argument() method.
    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")
    #calling parse_args() will return an object
    args = parser.parse_args()
    
    #to check whether mode is encrypt
    if(args.mode == 'encrypt'):
        #to get seed from args parameter
        seed = args.seed
        seed=int(seed)
        print("the seed value is ",seed)
        #following fuction is used to open file and read message
        f = open(args.inputFile,'r')
        message = f.read()
        #call function from other file to pass the parameter using object of that file
        Vigmat=rv.encrypt(seed,message,'encrypt')
        #below function is used to write output to file
        print("Encrypted Message is:",Vigmat)
        o = open(args.outputFile,'w')
        o.write(str(Vigmat))
        
        #below else part wil be decrypt function
    else:
        seed = args.seed
        seed=int(seed)
        f = open(args.inputFile,'r')
        message = f.read()
        Vigmat=rv.decrypt(seed,message,'decrypt')
        #below function is used to write output to file
        print("Decrypted Message is:",Vigmat)
        o = open(args.outputFile,'w')
        o.write(str(Vigmat))
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-m", "--mode", dest="mode", default = "encrypt", help="Encrypt or Decrypt")
    parser.add_argument("-i", "--inputfile", dest="plainText", 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()
    
    file = open(args.plainText,'r')
    message = file.read()
    seed = args.seed


    key = rv.keywordFromSeed(seed)
    print(key)

    if(args.mode == 'encrypt'):
        data = rv.encrypt(message,key,seed)
    else:
        data = rv.decrypt(message,key,seed)
        
    o = open(args.outputFile,'w')
    o.write(str(data))