Security and Cryptography in Python - Key Exchange(2)
Security and Cryptography in Python - Key Exchange(2)
def is_prime(p):
for i in range(2, p):
if p % i == 0:
return False
return True
print(is_prime(7))
Running Result:
import math
import random
def is_prime(p):
for i in range(2, math.isqrt(p)):
if p % i == 0:
return False
return True
def get_prime(size):
while True:
p = random.randrange(size, 2*size)
if is_prime(p):
return p
print(get_prime(10000))
Running Result:
相信未来 - 该面对的绝不逃避,该执著的永不怨悔,该舍弃的不再留念,该珍惜的好好把握。