コード例 #1
0
ファイル: test.py プロジェクト: iddinev/cryptography_1
#!/usr/bin/env python


from json import load
import encr_decr

input_cipher = 'test_encryptions.txt'
ciphertexts = open(input_cipher, 'r')

ciphertexts_list = load(ciphertexts)

key = ciphertexts_list.pop(len(ciphertexts_list) - 1)

output = encr_decr.decrypt(key,ciphertexts_list[0])
print(output)
output = encr_decr.decrypt(key,ciphertexts_list[1])
print(output)
print('xor of 2 is:', encr_decr.hexxor(ciphertexts_list[1],ciphertexts_list[0]))
コード例 #2
0
# work_list = ciphertexts_list
# work_list.remove(max_len_ciphertext)


while True:
    print("--------------")
    num_cipher_1 = input("# of cipher1: ")
    num_cipher_2 = input("# of cipher2: ")
    cipher_1 = ciphertexts_list[int(num_cipher_1) - 1]
    cipher_2 = ciphertexts_list[int(num_cipher_2) - 1]
    word = input("Choose string: ")
    hex_word = bytes(word, 'ascii').hex()
    print("Test word is '{}'".format(word))
    # pos = input("# of position in ciphertext: ")
    work_cipher = encr_decr.hexxor(cipher_1, cipher_2)
    output = encr_decr.decrypt(work_cipher[0:len(hex_word)], hex_word)
    print('output is: "{}" #{}/{}'.format(output.decode('ascii', 'backslashreplace'),\
    len(output.decode('ascii', 'backslashreplace')), len(cipher_2) / 2))











# for cipher in work_list:
    # print("--------------")
コード例 #3
0
ファイル: multipad.py プロジェクト: iddinev/cryptography_1

for cipher in work_list:
    print("--------------")
    print("ciphertext#:", ciphertexts_list.index(cipher) + 1)
    work_cipher = encr_decr.hexxor(max_len_ciphertext, cipher)
    work_len = len(work_cipher)
    for word in most_used_words:
        print("")
        print('next word: "{}"'.format(word))
        add = 'yes'
        while add == 'yes':
            add = input('Add something or change whole word?(a/c/else): ')
            if add == 'a':
                add_word = input('Add what??: ')
                word = word + add_word
            elif add == 'c':
                new_word = input('Change word to what??: ')
                word = new_word
            hex_word = bytes(word, 'ascii').hex()
            print('trial word is: "{}", hex: "{}"'.format(word, hex_word))
            print('..............')
            brk = ""
            for i  in range(0,(len(work_cipher)-len(hex_word))):
                if brk != "":
                    break
                else:
                    has_word = encr_decr.decrypt(hex_word, work_cipher[i:i+len(hex_word)])
                    print('result is: {}/{}, "{}", hex: "{}"'.format(i+1, work_len, has_word.decode('ascii', 'backslashreplace'), has_word.hex()))
                    brk = input("anykey cancels: ")
コード例 #4
0
ファイル: check_key.py プロジェクト: iddinev/cryptography_1
#!/usr/bin/env python


from json import load
import encr_decr


input_cipher = 'ciphertexts.txt'
ciphertexts = open(input_cipher, 'r')
ciphertexts_list = load(ciphertexts)
ciphertexts_len = [len(x) for x in ciphertexts_list]

print("================")
print("number of ciphertexts is: ", len(ciphertexts_list))
while True:
    print("--------------")
    num_cipher = input("# of cipher: ")
    ciphertext = ciphertexts_list[int(num_cipher) - 1]
    print('len of cipher is: ',len(ciphertexts_list[int(num_cipher) - 1]))
    pos = input("# of position in ciphertext: ")
    part_key = input("partial key: ")
    output = encr_decr.decrypt(part_key, ciphertext[int(pos) + 1: len(part_key)])
    print('output is: ',output.decode('ascii', 'backslashreplace'))