RSA

Posted hell0_w

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RSA相关的知识,希望对你有一定的参考价值。

使用openssl解public.key

openssl rsa -pubin -text -modulus -in warmup -in pub.key

#coding:utf-8
from Crypto.PublicKey import RSA
import gmpy2
import binascii
import rsa
‘‘‘
# openssl rsa -pubin -text -modulus -in warmup -in pub.key
# Public-Key: (256 bit)
# Modulus:
#     00:c0:33:2c:5c:64:ae:47:18:2f:6c:1c:87:6d:42:
#     33:69:10:54:5a:58:f7:ee:fe:fc:0b:ca:af:5a:f3:
#     41:cc:dd
# Exponent: 65537 (0x10001)
# 分解n http://factordb.com/
# 分解n yasu软件 factor(n)
n = "00:c0:33:2c:5c:64:ae:47:18:2f:6c:1c:87:6d:42:33:69:10:54:5a:58:f7:ee:fe:fc:0b:ca:af:5a:f3:41:cc:dd"
res = (n.replace(":",""))
print int(res,16)
‘‘‘

r = open(pub.key).read()
# c = open(‘flag.enc‘).read().encode(‘hex‘)
# c = int(c,16)
# print c
# print r
pub = RSA.importKey(r)
# print pub
n = long(pub.n)
e = long(pub.e)
# print n
# print e
p = 285960468890451637935629440372639283459
q = 304008741604601924494328155975272418463
e = 65537
l = (p-1) * (q-1)
d = int(gmpy2.invert(e,l))

# m = pow(c,d,n)

privatekey = rsa.PrivateKey(n,e,d,p,q)
with open(flag.enc,rb) as f:
    print rsa.decrypt(f.read(),privatekey)

 

以上是关于RSA的主要内容,如果未能解决你的问题,请参考以下文章

PHP RSA和RSA2加密算法代码

PHP RSA和RSA2加密算法代码

Go-RSA加密解密详解与代码

rsa解密错误

sap rsa5事务代码是在erp 中 还是在bw中

php RSA加密传输代码示例(轉)