RSA解密big算法独创

from Crypto.Util.number import long_to_bytes, bytes_to_longfrom Crypto.Util.strxor import strxor# RSA解密def rsa_decrypt(ciphertext, N, d):    plaintext_number = pow(ciphertext, d, N)    plaintext_bytes = long_to_bytes(plaintext_number)    return plaintext_bytesN = 89714050971394259600440975863751229102748301873549839432714703551498380713981264101533375672970154214062583012365073892089644031804109941766201243163398926438698369735588338279544152140859123834763870759757751944228350552806429642516747541162527058800402619575257179607422628877017180197777983487523142664487d = 4885628697024674802233453512637565599092248491488767824821990279922756927662223348312748794983451796542248787267207054348962258716585568185354414099671493917947012747791554070655258925730967322717771647407982984792632771150018212620323323635510053326184087327891569331050475507897640403090397521797022070233ciphertext = 67254133265602132458415338912590207677514059205474875492945840960242620760650527587490927820914970400738307536068560894182603885331513473363314148815933001614692570010664750071300871546575845539616570277302220914885734071483970427419582877989670767595897758329863040523037547687185382294469780732905652150451# RSA解密decrypted_bytes = rsa_decrypt(ciphertext, N, d)# 加密密钥key = b'Life is like an ocean only strong-minded can reach the other shore'# 由于原始消息长度决定了密钥的实际使用长度,需要从原始密钥中截取相应长度msg_length = len(decrypted_bytes)key = key[:msg_length]# XOR还原original_msg_bytes = strxor(decrypted_bytes, key)# 解码为字符串try:    original_message = original_msg_bytes.decode('utf-8')except UnicodeDecodeError:    original_message = original_msg_bytes.decode('utf-8', errors='ignore')

print(original_message)

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值