示例#1
0
def decrypt_file(filename):
    l = []
    key = input("Enter secret key: ")
    chunk = 16 * 1024
    with open(filename, "r") as r:
        while True:
            data = r.read(chunk)
            if len(data) == 0:
                break
            with open(filename, "w") as w:
                l.append(decrypt(data, key))
                w.write(decrypt(data, key))
    return l
示例#2
0
def get_msg():
    print("You entered '2': Get messages\n")
    #get messages and display them
    session_user.access_tok = refresh_token(constants.url, session_user.access_tok)
    messages = get_message(constants.url, session_user.username, session_user.access_tok)
    for message in messages:
        sender = message["sender"]
        json_object = json.loads(message["ciphertext"])
        message = decrypt(json_object, session_user.private_keys[sender].encode())

        print("Message = {}".format(message))
def display_data(trigger, wname=None):
    """ displays the website name, username and password
    :param trigger: used to display all passwords or single entry
    :param wname: website name
    """
    try:
        if (trigger == 1):
            query = '''SELECT * FROM Password'''

            for row in cur.execute(query):
                print("Website: ", row[0])
                print("Username: "******"Password: "******"'))
        else:
            query = '''SELECT * FROM Password WHERE website = ?'''
            for row in cur.execute(query, (wname, )):
                #print("Website: ", row[0])
                print("Username: "******"Password: "******"'))
    except Exception as e:
        print("Website doesn't exist in db")
        print(e)
示例#4
0
    def decryption(self):
        # Verify that the input for the key and intended message is correct type
        try:
            dekey = int(self.dekey_entry.get())
            demessage = str(self.retrieve_input(self.deT))

            new_message = de.decrypt(demessage, dekey)
            self.decrypted_answer.set(new_message)

        except TypeError:
            # For if the first decryption function does not work
            try:
                new_message = exception.decrypt(demessage, dekey)
                self.decrypted_answer.set(new_message)
            except TypeError:
                self.decrypted_answer.set("An error has occurred")
示例#5
0
def decrypt_file_data(filename):
    key = input("enter secret key: ")
    filename = filename[:-4] + "e" + filename[-4:]

    def read_file():
        #chunk = (16 * 1024) / 3 * 4
        #chunk -= chunk % 4
        chunk = 21868
        with open(filename, "r") as r:
            while True:
                data = r.read(int(chunk))
                if len(data) == 0:
                    break
                yield data

    outfile = filename[:-5] + filename[-4:]
    with open(outfile, "w") as w:
        for data in read_file():
            w.write(decrypt(data, key))
示例#6
0
def verify(transaction_id, file_hash, path_hash):

    transaction_data = get_transaction(transaction_id)

    if "Error" in transaction_data:
        if transaction_data[
                "Error"] == f'Transaction {transaction_id} not found.':
            return {"Error": 'Transaction ID Not Found'}
        else:
            return transaction_data

    transaction_data = transaction_data["data_string"]
    # print(transaction_data)
    # print('----1')
    final_hash = decrypt(transaction_data)
    # print(file_hash)
    # print('----2')
    calulated_final_hash = hash_path(file_hash, path_hash)
    # print(calulated_final_hash)
    # print('----3')
    check = final_hash == calulated_final_hash

    return {"verify": check}
示例#7
0
def decrypt_file(filename):
    key = input("enter key: ")
    with open(filename, "r") as r:
        data = r.read()
        with open(filename, "w") as w:
            w.write(decrypt(data, key))
示例#8
0
import encrypt_decrypt
import brute_force_func

alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

key = input("Enter a number between [1,25]: ")
while int(key) < 1 or int(key) > 25:
    print("You have entered a number outside the range. Try again")
    offset = input("Input a number between [0,25]: ")

text = input("Enter a word to have it encrypted: ")
text = text.upper()

print("----- Encryption/Decryption -----")
print("Encypted Message : " + encrypt_decrypt.encrypt(key, text))
print("Decrypted Message: " + encrypt_decrypt.decrypt(key, text))

print("----- Brute Force ---------------")
brute_force_func.brute_force()
示例#9
0
def Decode(image_path , key):
	#steganograph the image
	message = Steganography.decode(image_path)
	#decrypting the message
	decrypted = encrypt_decrypt.decrypt(message , key)
	return decrypted
 def test_decrypt(self):
     self.assertEqual(decrypt(self.input_message, self.encrypt_codes),
                      self.output_message, "Decryption failed")