这里有一个Rsa算法
首先来讲一下这个算法的基本原理和加密过程和解密过程
首先我们要知道的是:什么是加密解密
这个就是基本rsa加密啦
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| import hashlib import gmpy2 import rsa
p = 285960468890451637935629440372639283459 q = 304008741604601924494328155975272418463 e = 65537
n = 86934482296048119190666062003494800588905656017203025617216654058378322103517
d = gmpy2.invert(e,(q-1)*(p-1)) print(d)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| import hashlib import gmpy2 import rsa
p = 285960468890451637935629440372639283459 q = 304008741604601924494328155975272418463 e = 65537
n = 86934482296048119190666062003494800588905656017203025617216654058378322103517
d = gmpy2.invert(e,(q-1)*(p-1)) print(d) d = 81176168860169991027846870170527607562179635470395365333547868786951080991441
key = rsa.PrivateKey(n,e,d,p,q) print(key)
with open("flag.enc","rb") as f: print(rsa.decrypt(f.read(),key).decode())
|