libnum报错问题解决

之前在使用python libnum库时报错

附上报错内容

Traceback (most recent call last) :
  File" D:/python file/ctf/RSA共模攻击. py",line 37, in <module>
    main()
  File" D: /python file/ctf/RSA共模攻击. py", line 33, in main
    print(n2s(m)) #二进制转string
  File" D: pvthon2. 7libsite-packages libnumstrings. py", line 20, in n2s
    return str (codecs. decode(s,’hex' ),’ utf-8' )
TypeError: str() takes at most 1 argument (2 given)

当时在大佬的指导下换python3运行,安装完相关python库后运行,依然报错

附上报错内容

Traceback (most recent call last):
  File "D:/python file/ctf/RSA共模攻击.py", line 38, in <module>
    main()
  File "D:/python file/ctf/RSA共模攻击.py", line 33, in main
    print(n2s(m))
  File "D:python3.3libsite-packageslibnumstrings.py", line 20, in n2s
    return str(codecs.decode(s, 'hex'),'utf-8')
LookupError: unknown encoding: hex

在之后写题时发现运行别的脚本时也出现了相同的错误

于是开始思考是不是python库的问题

根据libnum库官方教程安装完成后成功解决问题

附上网址

https://github.com/hellman/libnum

下载后文件夹内容如下

使用如下命令安装

python setup.py install

安装完成后重新运行脚本,即可解决报错问题

原文地址:https://www.cnblogs.com/anweilx/p/12394295.html