Python3-我正在尝试实现256 AES解密和加密+蛮力为什么我遇到错误?

问题描述

错误是:

**追溯(最近一次通话最近):文件“ 256AESKeyCracker.py”,第10行,密码= AES.new(key,AES.MODE_EAX)AttributeError:模块'Crypto.Cipher.AES'没有属性' MODE_EAX'**

        import os,sys
        import subprocess
        import random
        from Crypto.Cipher import AES
        from random import choice
        # Brute Force AES Key Cracker File
        # Encryption:
        Data = open('Data.txt','r')
        key = b'WmZq4t7w!z%C*F-J@NcRfUjXn2r5u8x/'
        cipher = AES.new(key,AES.MODE_EAX)
        nonce = cipher.nonce
        ciphertext,tag = cipher.encrypt_and_digest(Data)
        # Decryption:
        # Brute Force Cycle Attempt Function
        path = 'Outputfile.txt'
        list = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()/?":;.>,<{][}+=-_`|\~'
        trys = 10000000
        length = 32
        new = open(path,'w')
        print(new)
         for i in range (0,trys)   :
           seg1 = "b'"
           seg2 = "'"
           #Remember to add random.choice() to A in order to set the correct amount of random
           #variable searches based on your grep search
           #New instances must be based on the length of the password searched for
           A = random.choice(list),random.choice(list),random.choice(list)
        B = "".join(A)
        key = A[:0] + seg1
        key = A[:33] + seg2
        # ^ Joining all segments -- DEPENDS ON LENGTH for 256 = 32 random.choice()
        f = open("Outputfile.txt","a")
        print("Try:",i,"Out of:",trys,B,file=f)
        # ^ Printing the output & writing to Outputfile

        cipher = AES.new(key,AES.MODE_EAX,nonce=nonce)
        plaintext = cipher.decrypt(ciphertext)

        try:
          cipher.verify(tag)
          print("The message is authentic",plaintext)

        except ValueError:
          print("Key incorrect or message corrupted")
          f.close()
          i += 1

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...