之前在使用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. 7\lib\site-packages \libnum\strings. 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.3\lib\site-packages\libnum\strings.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
安裝完成后重新運行腳本,即可解決報錯問題