Esempio n. 1
0
    def encodeVigenere(self, key):
        """endodes using a key"""

        key = key.upper().replace(" ", "")
        encode = Vig(key)
        cipherText = encode.encode(self.planeText)

        if (self.verbose == 1):
            print(cipherText)

        return (cipherText)
Esempio n. 2
0
    def decodeVigenere(self, key):
        """decode a viginere with known key"""

        key = key.upper().replace(" ", "")
        decode = Vig(key)
        planeText = decode.decode(self.cipherText)

        if (self.verbose == 1):
            print(planeText)

        return (planeText)
Esempio n. 3
0
    def test_encryption(self):
        plainText = 'TOBEORNOTTOBE'
        key = 'RELATIONSRELA'
        cipheredText = 'KSMEHZBBLKSME'

        self.assertEqual(cipheredText,
                         Vigenere(plainText, None, key).encryption())
Esempio n. 4
0
def main(argv):
    # Create instance of the CipherInterface
    cipher = CipherInterface()
    if len(argv) < 6:
        print("ERROR: not enough arguments filled out")
    else:
        cipherName = argv[1]
        key = argv[2]
        encOrDec = argv[3]
        textInput = argv[4] + ".txt"
        textOutput = argv[5] + ".txt"
        # print(cipherName)
        # print(key)
        # print(encOrDec)
        # print(textInput)
        # print(textOutput)

    # Open inputfile to read contents
    # assign contents to variable to encrypt/decrypt
    inputFile = open(textInput, "rt")
    contents = inputFile.read()
    inputFile.close()
    # print("File Contents")
    # print(contents)

    # Choose the cipher
    if cipherName.lower() == "plf":
        print("Playfair is chosen")
        cipher = Playfair()

    elif cipherName.lower() == "vig":
        print("Vigenere is chosen")
        cipher = Vigenere()

    elif cipherName.lower() == "rfc":
        print("Railfence is chosen")
        cipher = Railfence()

    elif cipherName.lower() == "rts":
        print("Row Transposition is chosen")
        cipher = RowTransposition()

    elif cipherName.lower() == "ces":
        print("Caesar is chosen")
        cipher = Caesar()

    # Set the encryption key
    cipher.setKey(key)
    if (encOrDec.lower() == "enc"):
        # Perform encryption
        outputText = cipher.encrypt(contents)
    else:
        # Perform decryption
        outputText = cipher.decrypt(contents)
    # Create and write into output file the outputText
    outputFile = open(textOutput, "w+")
    outputFile.write(outputText)
    outputFile.close()
Esempio n. 5
0
def cipherVig(key):
    #key = int(key)
    key = str(key)
    kek = Vigenere()
    text = Files.ReadFromFile()
    print('text:', kek.NormilizeText(text), 'key:', key)
    #a = input()

    Files.WriteInFile(kek.encrypt(key, kek.NormilizeText(text)))
Esempio n. 6
0
	menu += "|"+(" "*5)+subtitulo+(" "*28)+"|"+salto
	menu += linea+salto+"|"+(" "*5)+tit_algs+(" "*51)+"|"+salto
	menu += "|"+(" "*10)+tit_algo_uno+(" "*36)+"|"+salto
	menu += "|"+(" "*10)+tit_algo_dos+(" "*19)+"|"+salto+linea+salto
	menu += "|"+(" "*5)+tit_algo_tres+(" "*14)+"|"+salto
	menu += "|"+(" "*20)+tit_help_uno+(" "*13)+"|"+salto
	menu += "|"+(" "*30)+tit_help_dos+(" "*10)+"|"+salto+linea+salto
	menu += "|"+(" "*5)+tit_config+(" "*23)+"|"+salto
	menu += "|"+(" "*15)+tit_help_config_uno+(" "*8)+"|"+salto+linea+salto+cabecera
	print(menu)

else:
	# Se valida que el usuario escogió la opción de algoritmo Vigenere Autoclave
	if(sys.argv[1] == "-va"):

		vigenere = Vigenere()
		# En caso de que el usuario no coloque el parametro de ayuda y no hayan mas parametros,
		# de igual forma se muestra el menú
		if(len(sys.argv)) <= 3:

			sys.argv.insert(2, "-a")
		# Se valida que el usuario escogió el menú de ayuda y se muestra
		else:
			# Se realiza el cargue de la clave en claro y se quitan los espacios en blanco
			archivoClave = open(sys.argv[4], "r",encoding='ISO-8859-1')
			for lineaFileClave in archivoClave.readlines(): 
				clave = lineaFileClave
			archivoClave.close()
			clave = clave.replace(" ", "")
			tamClave = len(clave)
		# Se valida que el usuario escogió la opción de ayuda para algoritmo Virgene (Autoclave)
Esempio n. 7
0
def dechipherVig(key):
    key = str(key)
    kek = Vigenere()
    text = Files.ReadFromFile()
    Files.WriteInFile(kek.decrypt(key, kek.NormilizeText(text)))
@author: omeil
"""
import Vigenere as VV
from Vigenere import Vigenere as Vin
import numpy as np

pr = True

fake = Vin("FAKE")
cipher = "OCNYBIFHBRUPBNYAZGBBNBYESSYXYYNSQVMFDCHDNCSWHTEGNPMNLRSWXRYPPAFNGBUCFNGBISLRTRPILFXYXOMUXBTIHFXRHONRLQIOFYLRBBXNFGHVNLPMNOHJBRIONBKAIKBBLCGZUZXGTHBRBKQFCFHLFRFVZFUBCAZYORBRKLBAYZHRISLBYCYWFRLDSCGUXPCSUPHLIOHQZJPKMJHPMRQVWCXSFPHKFVYEFGMRYLXQDCGZTLEHBRTGSPLVWEFRBNKZPFNUTRUKCAVGUWYFYPBAYXXCQOHPBCOHFNGBTMIHKQUCLVXBQCGCVPJSMFACXWNULGMSHGEGQGAVOCNSSBNPUWLRWWPILCHMSMIHKFVRXYXBNOMFXQZSUEGGOUNBUPFONUXDSSYGACXFYGVFFRLRYSTSISRMVFNRXKJBAFAMSSMRGBUVYFXRISBBFCMSMFMCNDYFMRPGNGHKFWFVYRNMFNFNCSMVWCUVYTHJESHQHMS"
ln = VV.findL(cipher)

#keyholder = np.zeros(l)

for i in range(26):
    for j in range(26):
        for k in range(26):
            for l in range(26):
                for m in range(26):
                    for n in range(26):
                        keyholder = np.array((i, j, k, l, m, n))
                        key = ""
                        for i in range(len(keyholder)):
                            ch = chr((keyholder[i] % 26) + 65)
                            key += ch
                        vin = Vin(key)
                        decode = vin.decode(cipher)
                        if (pr == True):
                            print(decode)
Esempio n. 9
0
#!/usr/bin/env python3
''' decrypts the first passage'''
from Vigenere import Vigenere

keyword_1 = 'kryptos'
keyword_2 = 'abscissa'

with open('text_a.txt', 'r') as f:
    text = f.read().replace('\n', '').lower()

key_1 = 'betweensubtleshadingandtheabsenceoflightliesthenuanceofiqlusion'
text = text[len(key_1):].replace('?', '')

print(text)

my_decriptor_1 = Vigenere(keyword_1, keyword_2)
text_dec = my_decriptor_1.decrypt(text)
print(text_dec)
Esempio n. 10
0
 def test_encrypt(self):
     plaintext = "TOBEO"
     encrypt = "KSMEH"
     self.assertEqual(encrypt,Vigenere(plaintext, None).encrypt())
Esempio n. 11
0
 def test_encrypt(self):
     plaintext = "TOBEO"
     encrypt = "KSMEH"
     self.assertEqual(plaintext ,Vigenere(None,encrypt).decrypt())