Example #1
0
def openfn():
    global current_image_filename
    global cipher
    filename = filedialog.askopenfilename(title='Upload')
    current_image_filename = filename
    cipher = Cipher(in_url=current_image_filename)
    return filename
Example #2
0
    def encrypt_caesar():
        global cipher
        cipher.encode_caesar(int(shift.get("1.0", END)))

        global current_image_filename
        temp = os.path.basename(current_image_filename)

        current_image_filename = os.getcwd() + "\\Encoded_Images\\" + temp
        cipher = Cipher(in_url=current_image_filename)
        show_img(cipher.in_url)
Example #3
0
    def encrypt_vigenere():
        global cipher
        cipher.encode_vigenere(keyword.get("1.0", END))

        global current_image_filename
        temp = os.path.basename(current_image_filename)

        current_image_filename = os.getcwd() + "\\Encoded_Images\\" + temp
        cipher = Cipher(in_url=current_image_filename)
        show_img(cipher.in_url)
Example #4
0
    def show_possible_keys():
        global cipher
        xmult_table = Cipher.calculate_multiplicative_keys(cipher.xres)
        ymult_table = Cipher.calculate_multiplicative_keys(cipher.yres)
        x_values = "Possible X Values:"
        x_counter = 0
        for key in xmult_table:
            if x_counter < 20:
                x_values += (" " + str(key))
                x_counter = x_counter + 1

        y_values = "Possible Y Values:"
        y_counter = 0
        for key in ymult_table:
            if y_counter < 20:
                y_values += (" " + str(key))
                y_counter = y_counter + 1

        pprint.pprint(x_values)
        pprint.pprint(y_values)

        possibleXTextbox = Text(root,
                                height=int(root_height() * .0035),
                                width=int(root_width() * .0275),
                                wrap=WORD,
                                font=("Times New Roman", 16))
        possibleYTextbox = Text(root,
                                height=int(root_height() * .0035),
                                width=int(root_width() * .0275),
                                wrap=WORD,
                                font=("Times New Roman", 16))
        possibleXTextbox.place(x=930, y=530)
        possibleYTextbox.place(x=930, y=600)

        possibleXTextbox.config(state=NORMAL)
        possibleXTextbox.delete(1.0, "end")
        possibleXTextbox.insert(1.0, x_values)
        possibleXTextbox.config(state=DISABLED)

        possibleYTextbox.config(state=NORMAL)
        possibleYTextbox.delete(1.0, "end")
        possibleYTextbox.insert(1.0, y_values)
        possibleYTextbox.config(state=DISABLED)
Example #5
0
    def encrypt_multiplicative():
        global cipher
        cipher.encode_multiplicative(int(xShift.get("1.0", END)),
                                     int(yShift.get("1.0", END)))

        global current_image_filename
        temp = os.path.basename(current_image_filename)

        current_image_filename = os.getcwd() + "\\Encoded_Images\\" + temp
        cipher = Cipher(in_url=current_image_filename)
        show_img(cipher.in_url)
Example #6
0
def main():
    file_path = r"C:\Users\Shawn Huesman\Downloads\Evariste_galois.jpg"
    # file_path = r"C:\Users\Shawn Huesman\Github\Crymage\Examples\Encoded_Images\multiencoded.jpg"
    mcipher = Cipher(in_url=file_path)
    Cipher.encode_caesar(mcipher, 500)
    # Initialise le message
    msg = ""
    # Boucle sur tous les charactères du chiffrement
    for l in cipher:
        # Vérifie si le charactère fait partie de l'alphabet
        if l.lower() in alph:
            # Détermine la position de la lettre originale
            index = (MAP[l.lower()] - key) % MOD
            # Ajoute la lettre
            msg += alph[index]
        else:
            # Ajoute le charactère
            msg += l
    # Retourne le message déchiffré
    return msg


CIPHER = Cipher()
alph = CIPHER.get_alph()
MAP = CIPHER.get_map()

cipher = CIPHER.caesar("Allo")

# Teste les clés de 0 à 25
for i in range(len(alph)):
    # Obtient le message selon la 'ie' clé
    msg = caesar_decoder(cipher, i, alph, MAP)
    if (CIPHER.caesar_bonne_cle(msg, "Allo")):
        break

print(msg, i)
Example #8
0
def main():
    # file_path = r"galois.jpg"
    file_path = r"Examples\Encoded_Images\galois.jpg"
    mcipher = Cipher(in_url=file_path)
    Cipher.decode_affine(mcipher, 667, 905, 500)