用rsa加密和解密文件的简单工具
cryptor的Python项目详细描述
加密游乐场
在python中对crypto libs进行各种测试的地方
来源
安装
Conda-车窗
conda install -c conda-forge pycryptodomeex
pip-linux
- 从git获得它
cd ~/_projects/github/ git clone https://github.com/pavelsuk/crypto_playground crypto_playground cd ~/_projects/github/crypto_playground
- 创建虚拟环境
sudo apt install python3-venv cd ~/_projects/github/crypto_playground python3.6 -m venv env source env/bin/activate
- 安装软件包
cd ~/_projects/github/crypto_playground git fetch git merge source env/bin/activate pip install -r requirements.txt
用法
生成密钥对
# generate private_key.pem (without password) and public_key.pem: python cryptorshell.py generate # generate key pair (password protected) to specific files: python cryptorshell.py generate --privkey private_pwd.pem --pubkey public_pwd.pem --pwd mylittlesecretpwd
加密和解密文件
# encrypt little_secret.txt to little_secret.txt.encrypted using default public_key.pem python cryptorshell.py encrypt little_secret.txt # decrypt little_secret.txt.encrypted to little_secret.txt.dec using default public_key.pem python cryptorshell.py decrypt little_secret.txt.encrypted little_secret.txt.dec # encrypt file little_secret.txt to encrypted_secret.enc using public key public_pwd.pem python cryptorshell.py encrypt little_secret.txt encrypted_secret.enc --pubkey public_pwd.pem # decrypt encrypted_secret.enc to encrypted_secret.dec using password protected private key python cryptorshell.py decrypt encrypted_secret.enc decrypted_secret.dec --privkey private_pwd.pem --pwd mylittlesecretpwd