相关疑难解决方法(0)

AttributeError:模块“时间”在Python 3.8中没有属性“时钟”

我已经编写了生成公共和私有密钥的代码。它在Python 3.7上运行良好,但在Python 3.8中失败。我不知道在最新版本中它怎么会失败。为我提供一些解决方案。

这是代码:

from Crypto.PublicKey import RSA


def generate_keys():
    modulus_length = 1024
    key = RSA.generate(modulus_length)
    pub_key = key.publickey()
    private_key = key.exportKey()
    public_key = pub_key.exportKey()
    return private_key, public_key


a = generate_keys()
print(a)
Run Code Online (Sandbox Code Playgroud)

Python 3.8版本中的错误:

Traceback (most recent call last):
  File "temp.py", line 18, in <module>
    a = generate_keys()
  File "temp.py", line 8, in generate_keys
    key = RSA.generate(modulus_length)
  File "/home/paulsteven/.local/lib/python3.8/site-packages/Crypto/PublicKey/RSA.py", line 508, in generate
    obj = _RSA.generate_py(bits, rf, progress_func, e)    # TODO: Don't use legacy _RSA module
  File "/home/paulsteven/.local/lib/python3.8/site-packages/Crypto/PublicKey/_RSA.py", line 50, …
Run Code Online (Sandbox Code Playgroud)

python attributeerror pycrypto python-3.8

5
推荐指数
7
解决办法
2194
查看次数

标签 统计

attributeerror ×1

pycrypto ×1

python ×1

python-3.8 ×1