我的代码有一些错误,有人可以检查一次吗

I have some error with my code, can someone please review it once

[https://github.com/Simrantiwarii/RSA-ENCYRPTION/blob/1e88b32c9d1e133886f73115374d5018d946f5b8/Untitled6.ipynb] 有人可以查看此代码并告诉我为什么会出现此错误:

TypeError                                 Traceback (most recent call last)
<ipython-input-43-01ba3f5a9a3e> in <module>
     88 
     89 if __name__ == '__main__':
---> 90     public_key,private_key = generate_keyPairs()
     91     print("Public: ",public_key)
     92     print("Private: ",private_key)

<ipython-input-43-01ba3f5a9a3e> in generate_keyPairs()
     53         E = generatenextPrime(E)
     54         #print(type(F))
---> 55         g = gcd(E,phi)
     56     #print("E=",E,)
     57     #print(type(E))

<ipython-input-43-01ba3f5a9a3e> in gcd(a, b)
     11 def gcd(a, b):
     12     while b != 0:
---> 13         a, b = b, a % b
     14     return a
     15 

TypeError: unsupported operand type(s) for %: 'NoneType' and 'int'

我正在尝试研究 RSA 中加密密钥组件 'e' 的性质。

正如错误信息所说:a 不是数字而是 None。我假设 generatenextPrime(E) returns None

def generatenextPrime(num):
    E = num+1
    #print ("E= %d" %E)
    if is_prime(E):
        return E
    else:
        num += 1  # <--- nothing (None) is returned in that case

试试这个

def generatenextPrime(num):
    e = num
    while not is_prime(e):
        e += 1
    return e