Beispiel #1
0
    def __init__(self, root):

        self.encryptor = Encryptor()
        self.decryptor = Decryptor()

        self.root = root
        self.width = 400
        self.height = 160
        self.screen_width = self.root.winfo_screenwidth()
        self.screen_height = self.root.winfo_screenheight()
        self.x = (self.screen_width / 2) - (self.width / 2)
        self.y = ((self.screen_height / 2) - (self.height / 2)) * 0.6
        self.root.geometry("%dx%d+%d+%d" % (self.width, self.height, self.x, self.y))

        self.root.configure(background='#3B3B3B')
        self.root.title("timi")
        self.root.resizable(False, False)

        self.input_entry = Entry(self.root, font="Arial 10", relief="flat")
        self.input_entry.place(x=40, y=18, width=320, height=25)

        self.encrypt_button = Button(self.root, command=self.encrypt, fg="#000000", font="Arial 8 bold", activeforeground="#FFFFFF",
                             activebackground="#ADADAD", bg="#D3D3D3", text='encrypt', relief="flat")
        self.encrypt_button.place(x=120, y=55, width=70)

        self.decrypt_button = Button(self.root, command=self.decrypt, fg="#000000", font="Arial 8 bold", activeforeground="#FFFFFF",
                                     activebackground="#ADADAD", bg="#D3D3D3", text='decrypt', relief="flat")
        self.decrypt_button.place(x=210, y=55, width=70)

        self.scrollbar = Scrollbar(root)
        self.output_field = Text(root, height=3)
        self.scrollbar.place(x=342, y=92, width=18, height=52)
        self.output_field.place(x=40, y=92, width=300)
        self.output_field.config(yscrollcommand=self.scrollbar.set)
        self.scrollbar.config(command=self.output_field.yview)
 def deleteCustomData(self):
     temp_encryptor = Encryptor.Encryptor("")
     if self.DatabaseTable.selectionModel().hasSelection():
         data_id = self.DatabaseTable.currentRow()+1
         temp_encryptor.deleteCustomData(data_id)
         print("tried to delete with id: " + str(data_id))
         self.LoadData()
     else:
         print("Select Credentials to delete")
Beispiel #3
0
def encrypt(fileName, key):
    with open(fileName, "r+b") as file2Encrypt:
        data = file2Encrypt.read()
        encryptor = Encryptor(key, iv)  
        cipherText = encryptor.encrypt(data)
        cipherText = base64.b64encode(cipherText)
        with open("{}.enc".format(fileName), "wb") as encryptedFile:
            encryptedFile.write(cipherText)
    os.remove(fileName)
Beispiel #4
0
 def jinenastaveniklice(self, data):
     #dela zajimave veci, ale jen v urcitem pripade
     self.cli.generate_shared_secret(int(data.decode()),
                                     echo_return_key=True)
     superklic = str(self.cli.shared_secret)
     xy = hashlib.sha256(superklic.encode()).hexdigest()[:32]
     print("2222222222222222222222222222")
     self.cislo = 2
     print(xy)
     self.mujAES = Encryptor.Encryptor(xy)
Beispiel #5
0
 def nastavitKlic(self, data):
     #nastavuje klic na zaklade dat ktere dostane
     self.cli.generate_shared_secret(int(data.decode()),
                                     echo_return_key=True)
     superklic = str(self.cli.shared_secret)
     xy = hashlib.sha256(superklic.encode()).hexdigest()[:32]
     print("111111111111111111111")
     self.cislo = 1
     print(xy)
     self.mujAES = Encryptor.Encryptor(xy)
     self.sock.send(b'\x14' + str(self.cli.public_key).encode())
Beispiel #6
0
def decrypt(fileName, key):
    try:
        with open(fileName, "r+b") as file2Decrypt:
                data = base64.b64decode(file2Decrypt.read())
                decryptor = Encryptor(key, data[:AES.block_size])
                plainText = decryptor.decrypt(data)
                with open(fileName[:-4], "wb") as decryptedFile:
                    decryptedFile.write(plainText)
        os.remove(fileName)
    except:
        print("Cannot decrypt this file")
    def LoadData(self):
        passwrd = self.pwdLine.text()
        encryptor = Encryptor.Encryptor(passwrd)

        #delete existing data
        while self.DatabaseTable.rowCount() > 0:
            self.DatabaseTable.removeRow(0)

        results = encryptor.getDecreptedData()
        for row_number, row_data in enumerate(results):
            self.DatabaseTable.insertRow(row_number)
            for column_number, data in enumerate(row_data):
                 self.DatabaseTable.setItem(row_number, column_number, QtWidgets.QTableWidgetItem((data.decode())))
 def pwdChange(self):
     pwdChangeDialog = QtWidgets.QDialog()
     ui = Ui_PwdChangeDialog()
     ui.setupUi(pwdChangeDialog)
     pwdChangeDialog.show()
     ui.oldPwdLine.setText(self.pwdLine.text())
     rsps = pwdChangeDialog.exec_()
     if rsps == QtWidgets.QDialog.Accepted:
         oldpwd = ui.oldPwdLine.text()
         newpwd = ui.newPwdLine.text()
         tempEncryptor = Encryptor.Encryptor(oldpwd)
         tempEncryptor.encryptWithNewPassword(newpwd)
         self.pwdLine.setText(newpwd)
         self.LoadData()
Beispiel #9
0
def main():
    # getting Inputs
    inputs = KnapsackView.inputs()

    # Encryption Part
    encryptor = Encryptor.Encryptor(inputs.multiplier,
                                    inputs.inverse_multiplier, inputs.modulus,
                                    inputs.simpleKnapsack, inputs.message)
    encrypted_message = encryptor.encrypt()

    #Decryption Part
    decryptor = Decryptor.Decryptor(inputs.inverse_multiplier, inputs.modulus,
                                    encrypted_message, inputs.simpleKnapsack)
    encrypted_message = decryptor.decrypt()
 def addDataGui(self):
     addDataDialog = QtWidgets.QDialog()
     ui = Ui_addDataDialog()
     ui.setupUi(addDataDialog)
     addDataDialog.show()
     ui.lineEdit_4.setText(self.pwdLine.text())
     rsps = addDataDialog.exec_()
     if rsps == QtWidgets.QDialog.Accepted:
         site = ui.lineEdit.text()
         username = ui.lineEdit_2.text()
         pwd = ui.lineEdit_3.text()
         decryptPwd = ui.lineEdit_4.text()
         encryptor = Encryptor.Encryptor(decryptPwd)
         encryptor.addData(site, username, pwd)
         self.pwdLine.setText(decryptPwd)
     self.LoadData()
    def search(self):
        #Get all data
        #Decrypt all data with the given password and save in python dictionary (list?)
        #Search in the decrypted list for the given param 
        searchDialog = QtWidgets.QDialog()
        ui = Ui_Dialog()
        ui.setupUi(searchDialog)
        passwrd = self.pwdLine.text()
        encryptor = Encryptor.Encryptor(passwrd)
        try:    
            results = encryptor.getDecreptedData()
        except:
            print("Something Went Wrong")
            return
        queryTranslate = {
            'Site': 0, 
            'Username/Email':1
        }
        searchparam = self.searchDropdown.currentText()
        t = self.pwdLine_2.text()
        final = []
        try:
            for result in results:
                if t in result[queryTranslate[searchparam]].decode():
                    final.append(result)
        except:
            pass
        if len(final) == 0:
            self.showError()
            return
        for row_number, row_data in enumerate(final):
            ui.dataDisplayTable.insertRow(row_number)
            for column_number, data in enumerate(row_data):
                ui.dataDisplayTable.setItem(row_number, column_number, QtWidgets.QTableWidgetItem(data.decode()))
        searchDialog.show()

        searchDialog.exec_()
 def deleteAllData(self):
     temp_encryptor = Encryptor.Encryptor("")
     temp_encryptor.deleteData()
     while self.DatabaseTable.rowCount() > 0:
         self.DatabaseTable.removeRow(0)
import PasswordGenerator as generator
import Encryptor as enc

password_generator = generator.Password_generator()
password = password_generator.generate_password()
encryptor = enc.Encryptor()
en = encryptor.encrypt_aes(password)
print(en)
de = encryptor.decrypt_aes(en)
print(de)