getPrime() method working. gets random prime based on bit size.
This commit is contained in:
parent
7fe7065700
commit
1a591cc75e
13
rsa.py
13
rsa.py
@ -4,16 +4,19 @@
|
|||||||
# Hesham Banafa
|
# Hesham Banafa
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
import os
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
#test isPrime method
|
#Prime of size 32 bit random
|
||||||
for i in range(2,999999):
|
print(getPrime(32))
|
||||||
if isPrime(i):
|
|
||||||
print(i, 'is prime')
|
|
||||||
|
|
||||||
def getPrime(bits):
|
def getPrime(bits):
|
||||||
pass
|
while True:
|
||||||
|
x = int.from_bytes(os.urandom(int(bits/8)),"little")
|
||||||
|
if isPrime(x):
|
||||||
|
return x
|
||||||
|
|
||||||
|
|
||||||
def isPrime(number):
|
def isPrime(number):
|
||||||
if number == 2:
|
if number == 2:
|
||||||
|
Loading…
Reference in New Issue
Block a user