摘要
SageMath是每个密码手必备工具,本文介绍了SageMath9.3和在Linux Kali下SageMath10.4的安装和使用,以及Crypto.Util.Number模块不能识别等问题的解决方法。
SageMath 9.3 安装
SageMath 9.3可以使用Notepad编辑和保存代码,非常方便。
官网下载(Windows): SageMath 9.3
Kali Linux 安装
搜索"启用或关闭Windows功能"勾选"适用于Linux的Windows子系统" :
在Microsoft Store上安装Kali Linux,设置用户名和密码,其中密码没有回显。如果忘记密码,可以用pwd命令重置密码。
完成后应回显:
┌──(root㉿你的用户名)-[~]
└─#
SageMath 10.4 安装
SageMath 10.4 相较于SageMath 9.3,不能使用Notepad,而且没有Window版本的。
但SageMath 10.4 具有不可取代的优势,算法优化更好,支持更多函数,有的程序只能用SageMath 10.4 实现。
官网的教程:从 conda-forge 安装SageMath10.4
注意:Mamba现在已经被弃用!!请使用Conda!!
1. 安装Miniforge
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-(uname)-(uname -m).sh"
bash Miniforge3-(uname)-(uname -m).sh
2. 安装sage
使用 conda
创建包含 SageMath 的新 conda 环境(其中X 是 Python 的版本,可以用 python3 -v
来查询):
conda create -n sage sage python=X
3. 启动sage
请记住启动sage的命令:
┌──(root㉿*****)-[~]
└─# conda activate sage
(sage) ┌──(root㉿*****)-[~]
└─# sage
可能的问题
1. SageMath 9.3 无法使用sage
请检查文件是否为sage文件,创建(New)时请选择SageMath 9.3 而不是 python 3。
2. Crypto.Util.number模块无法被识别
2.1 安装模块
首先安装相关模块,输入命令:
pip install pycryptodome
pip install pycrypto
pip install Crypto
其中后两条命令可能是非必要的,尚未测试。
如果提示pip版本低请先更新pip:
pip install --upgrade pip
2.2 重命名
对于SageMath 9.3,找到"SageMath 9.3\runtime\opt\sagemath-9.3\local\lib\python3.7\site-packages"
将"crypto"文件夹重命名为"Crypto"。
对于SageMath 10.4,无需重命名。
Comments NOTHING