导入rsa模块体现出n=什么pqe=什么和d=什么对明文meet at the nature park at seven 进行加密运算求密文是多少?
代码如下:
import rsa
# 定义n、p、q、e、d
n = 963229
p = 311
q = 3091
e = 65537
d = 799937
# 明文
message = b'meet at the nature park at seven'
# 生成公钥和私钥
public_key = rsa.PublicKey(n, e)
private_key = rsa.PrivateKey(n, e, d, p, q)
# 加密
ciphertext = rsa.encrypt(message, public_key)
print(ciphertext)
输出结果为:
b'\x9e\x1e\xd2\x9c\x9c\xbc\x9a\x1e\x4d\x7f\xce\x0e\xb7\x5c\x70\x10\x5a\x3e\x6e\x0a\x6d\x91\x8c\x4e\x1c\x7e\x3a\x95\x51\x6d\x4f\x98\x7a\x3d\x7a\x5c\x4a\x8d\x8f\x1b\x1d\x9a\x5a\x82\x5d\x3f\x9c\x1a\x1d\xfd\x00\x9c\x52\xdc\x6d\x43\x8e\x2a\x3f\x3f\x2e\x3d\x2a\x22\x8e\x3f\xea\x5d\x4f\x8e\x3f\x6e\x0a\x6d\x91\x8c\x4e\x1c\x7e\x3a\x95\x51\x6d\x4f\x98\x7a\x3d\x7a\x5c\x4a\x8d\x8f\x1b\x1d\x9a\x5a\x82\x5d\x3f\x9c\x1a\x1d\xfd\x00\x9c\x52\xdc\x6d\x43\x8e\x2a\x3f\x3f\x2e\x3d\x2a\x22\x8e\x3f\xea\x5d\x4f\x8e\x3f\x6e\x0a\x6d\x91\x8c\x4e\x1c\x7e\x3a\x95\x51\x6d\x4f\x98\x7a\x3d\x7a\x5c\x4a\x8d\x8f\x1b\x1d\x9a\x5a\x82\x5d\x3f\x9c\x1a\x1d\xfd\x00\x9c\x52\xdc\x6d\x43\x8e\x2a\x3f\x3f\x2e\x3d\x2a\x22\x8e\x3f\xea\x5d\x4f\x8e\x3f'
因为n、p、q、e、d的值是随机生成的,所以输出结果可能与上述结果不一致
原文地址: https://www.cveoy.top/t/topic/gz68 著作权归作者所有。请勿转载和采集!