Compare commits

..
5 Commits
Author SHA1 Message Date
Alex_jzr 9c8e07610d 删除 key/rsamake.py 2025-09-14 09:47:50 +08:00
Alex_jzr c14cfe14b9 删除 key/public_key.pem 2025-09-14 09:47:31 +08:00
Alex_jzr 1b6add1506 删除 key/private_key.pem 2025-09-14 09:47:18 +08:00
Alex_jzr 67176d865c 上传文件至 / 2025-09-14 04:07:36 +08:00
alex edb6709b4b 基础框架,有大bug 2025-09-14 03:41:16 +08:00
-38
View File
@@ -1,38 +0,0 @@
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.backends import default_backend
# 生成私钥
private_key = rsa.generate_private_key(
public_exponent=65537,
key_size=2048,
backend=default_backend()
)
# 获取公钥
public_key = private_key.public_key()
# 序列化私钥
private_pem = private_key.private_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.PKCS8,
encryption_algorithm=serialization.NoEncryption()
)
# 序列化公钥
public_pem = public_key.public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo
)
# 保存私钥到文件
with open('private_key.pem', 'wb') as f:
f.write(private_pem)
# 保存公钥到文件
with open('public_key.pem', 'wb') as f:
f.write(public_pem)
print("RSA密钥对生成成功!")
print("私钥已保存到: private_key.pem")
print("公钥已保存到: public_key.pem")