Python用于处理数据和文件加密解密的库
Project description
zdppy_password
Python密码工具
项目地址:https://github.com/zhangdapeng520/zdppy_password
版本历史
- 2022年3月29日 版本0.1.0 兼容Python和Go的AES RSA加密解密算法
常用命令
生成私钥
openssl genrsa -out private.pem 1024
生成公钥
openssl rsa -in private.pem -pubout -out public.pem
使用案例
案例1:AES加密和解密
from zdppy_password.aes import Aes
aes = Aes()
res = aes.encrypt(b'{"cmd": 3000, "msg": "ok"}').decode(encoding='utf-8')
print(res)
print(aes.decrypt(res))
# 从go复制过来的
print(aes.decrypt("0qg69fOjmE0oR59muWdXoWhr5d4Z0XyQaC69684mAsw="))
案例2:RSA加密和解密
from zdppy_password.rsa import Rsa
import json
rsa = Rsa()
data = {"username": "张大鹏", "age": 22}
data = json.dumps(data)
print(data)
# 加密
secret = rsa.encrypt(data, "public.pem")
# 解密
print(json.loads(rsa.decrypt(secret, "private.pem")))
# 从go复制过来的
data = "NoA3e0HDMhj7nrwKUx975lUZgjRIA1ZFcEBLeAvgYQ7Nu7toic7xXtg9qmD+wr6soZzb6Gl37H1I5j9OlOTR9igQ+p1pXPOWo47DyDpw3UjiQ6eOAYmyT53lMUGylLZIKHhnbpea5Qpjl+dHrWVYsQ864/asS1ewe9k2hR+BlkBuZSP8p6oiJ+BBOVYckqPFf6PWBjAFGAMridMXglYrKZ2v7+QdwU4mq2YEBVD5XdY70lIEg4XIY8Wb6n5tBB5XkzLsqd22XcBhnEPGLmMC4fuEMyLptH5dMGF/Ogi9YDAP/rKvzdTTpFXPLPh5eeqMMXAS5+AigE1jx1M3w+7IUw=="
print(rsa.decrypt(data, "private.pem"))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
zdppy_password-0.1.0.tar.gz
(28.5 kB
view details)
Built Distribution
File details
Details for the file zdppy_password-0.1.0.tar.gz
.
File metadata
- Download URL: zdppy_password-0.1.0.tar.gz
- Upload date:
- Size: 28.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.7 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e949cca595f209e540ff507574753ff03772635365f2ade6c609a3c0775095be |
|
MD5 | fc9a3c2ebb71278004ed89927ebee844 |
|
BLAKE2b-256 | f8587d25a928981421c109710f5490fcbdcaa42bb794a9e2db42493d096942b1 |
File details
Details for the file zdppy_password-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: zdppy_password-0.1.0-py3-none-any.whl
- Upload date:
- Size: 36.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.9.7 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97cf65a8ec3482f3c8adf7c279fd309d0789993387b1947e6dab77d56b45f107 |
|
MD5 | 81a2389a3121d6b183b88f38bc61359a |
|
BLAKE2b-256 | 69785fce73c2c4f31291737d7caa31657892db991f65a76b972556a46c7072c7 |