有些值可用于rsa加密/解密,但有些则不能

时间:2019-05-03 15:44:29

标签: python rsa

我已经在python中创建了一个程序,以使用RSA算法对解密进行加密,但是它适用于所有值

我有(p,q,n,phi(n),e,d)=(1033,5039,5205287,5199216,7,4456471)

#this is the encryption part
def RSA():
    global D
    L = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z",' ','!','?','(',')','/','.',',',"'"]
    N = ["01",'02',"03","04","05",'06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35']
    C = ""
    M = input("Message to encrypt: ")
    for l in M:
        A = L.index(l)
        B = N[A]
        C += B
        D = "1" + C
    print(D)
    def main1():
        n = 5205287
        e = 7
        EN = (int(D)**e) % n
        print(EN)
    main1()
    A = input()
    if A == "a":
        RSA()
RSA()


#ignore the first part of the code

只有一些数字有效并且我得到了正确的解密,但另一些我得到了完全不同的数字

0 个答案:

没有答案