def codificar():
     if pwd.text() == '' or len(pwd.text()) <= 5:
         QMessageBox.warning(
             self.ferramentas, 'Atenção',
             'Digite antes uma palavra com mais de 6 caracteres\npara que a codificação seja bem sucedida..'
         )
     else:
         password = encryptMessage(None, pwd.text())
         return labelPwd.setText(password)
Exemplo n.º 2
0
def main():
    # Read data
    dataFile = open('./testData.txt', encoding='utf-8')
    data = dataFile.read()
    dataFile.close()
    # Generate a key
    key = simpleSubCipher.getRandomKey()
    print('key: %s' % key)
    # Encrypt text
    secretData = simpleSubCipher.encryptMessage(key, data)
    # print(secretData)
    input()
    # BF method to hack this text
    letterMapping = simpleSubHacker.hackSimpleSub(secretData)
    print(letterMapping)
Exemplo n.º 3
0
def encryptMessage(key, message):
    key = makeSimpleSubKey(key)
    return simpleSubCipher.encryptMessage(key, message)
Exemplo n.º 4
0
def encryptMessage(key, message):
    key = makeSimpleSubKey(key)
    return simpleSubCipher.encryptMessage(key, message)
Exemplo n.º 5
0
        cipher_text = input(cipher_text_hack)
        print(affineHacker.hackAffine(cipher_text))
        to_continue()

###############################################################################
#                               SUBSTITUTION BRANCH
################################################################################                        
    elif user_input in ['Substitution, Encrypt', 'Substitution', 'Se', '10', '10.']:
        plain_text = input(plain_text_message)
        valid = True
        while valid:
            have_key = input("Do you have an encryption key already?\nY/N>> ").upper().strip()
            if have_key.startswith("Y"):
                key = input("Enter key:\n>> ").upper().strip()
                if simpleSubCipher.keyIsValid(key):
                    print(simpleSubCipher.encryptMessage(key, plain_text))
                    valid = False
                else:
                    print(alpha_key_error)
            elif have_key.startswith("N"):
                key = simpleSubCipher.getRandomKey()
                print("Your key is:\n>> ", key)
                to_continue()
                print(simpleSubCipher.encryptMessage(key, plain_text))
                to_continue()
                valid = False
            else:
                print("Please make a valid selection.")

    elif user_input in ['Substitution, Decrypt', 'Sd', '11', '11.']:
        cipher_text = input(cipher_text_decrypt)