一招破解所有网页的加密源代码

javascript :s=document.documentElement.outerHTML;document.write('<body></body>');document.body.innerText=s;

转载于:https://www.cnblogs.com/peirunou/archive/2008/12/06/1349285.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是Python实现的一整套RSA加密算法源代码: ```python import random import math def is_prime(n): """判断一个数是否为素数""" if n < 2: return False for i in range(2, int(math.sqrt(n))+1): if n % i == 0: return False return True def gcd(a, b): """计算a和b的最大公约数""" while b != 0: a, b = b, a % b return a def extended_gcd(a, b): """计算a和b的最大公约数以及贝祖等式中的x和y""" if b == 0: return (a, 1, 0) else: d, x, y = extended_gcd(b, a % b) return (d, y, x - (a // b) * y) def generate_keypair(p, q): """生成公钥和私钥""" n = p * q phi = (p - 1) * (q - 1) e = random.randint(1, phi-1) while gcd(e, phi) != 1: e = random.randint(1, phi-1) d = extended_gcd(e, phi)[1] if d < 0: d += phi return ((e, n), (d, n)) def encrypt(plaintext, public_key): """使用公钥加密信息""" e, n = public_key ciphertext = [pow(ord(char), e, n) for char in plaintext] return ciphertext def decrypt(ciphertext, private_key): """使用私钥解密信息""" d, n = private_key plaintext = [chr(pow(char, d, n)) for char in ciphertext] return ''.join(plaintext) if __name__ == '__main__': p = 61 q = 53 if not (is_prime(p) and is_prime(q)): raise ValueError('p和q必须是素数!') public_key, private_key = generate_keypair(p, q) message = 'Hello, World!' ciphertext = encrypt(message, public_key) plaintext = decrypt(ciphertext, private_key) print('公钥:', public_key) print('私钥:', private_key) print('明文:', message) print('密文:', ciphertext) print('解密后的明文:', plaintext) ``` 在这个示例中,我们使用61和53两个素数生成RSA加密算法的公钥和私钥,并使用公钥加密一条消息,然后使用私钥解密该消息。注意,为了简化示例,我们使用了ASCII码来表示字符,但在实际应用中,我们应该使用更安全的加密方式来保护敏感信息。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值