zoukankan      html  css  js  c++  java
  • 简单的RSA题目

    今天做了一道简单的RSA可惜不会写脚本,脚本还是看的WP大佬的~~~

    首先对RSA的参数了解:

    e  公钥

    d 私钥

    n 模数(大质数,可由p和q相乘得到)

    c 密文 

    m 明文


       注意!!!!!!这个脚本需要python2/3的gmpy2模块 和rsa模块(安装详情可搜索本博客)

    • 看到公钥直接丢到openssl里 openssl>>   然后输入如下命  rsa -pubin -text -modulus -in warmup -in 公钥文件名.key 

    然后结果应该如下图

    这样就把 e 和 n 解出来了 (不过n解出来的是十六进制,需要先换算为十进制)

    用python

    n=98432079271513130981267919056149161631892822707167177858831841699521774310891           (记得把后面的L去掉)

    在使用大质数分解网站分解n         网站地址:http://factordb.com/index.php

    • 到这里RSA的参数已经齐全了 

      p = 302825536744096741518546212761194311477

      q = 325045504186436346209877301320131277983

      n = 98432079271513130981267919056149161631892822707167177858831841699521774310891
      e = 65537

    • 使用rsatools 得到pem格式私钥  python rsatools.py -p p参数 -q q参数 -e e的值 -o pri.pem
    • 使用openssl解出 openssl rsautl -decrypt -in 加密文件名 -inkey 私钥 -out 输出文件名 
  • 相关阅读:
    第一次热身赛和正式比赛感想
    简明解释算法中的大O符号
    poj 3045
    poj 3104
    poj 3273
    poj 3258
    poj 2456
    二分法小结
    Poj 2718 Smallest Difference
    GCJ——Crazy Rows (2009 Round 2 A)
  • 原文地址:https://www.cnblogs.com/threesoil/p/9980209.html
Copyright © 2011-2022 走看看