getPrime() method working. gets random prime based on bit size.

This commit is contained in:
HeshamTB 2020-04-16 05:54:36 +03:00
parent 7fe7065700
commit 1a591cc75e
Signed by: Hesham
GPG Key ID: 74876157D199B09E

13
rsa.py
View File

@ -4,16 +4,19 @@
# Hesham Banafa
import math
import os
def main():
#test isPrime method
for i in range(2,999999):
if isPrime(i):
print(i, 'is prime')
#Prime of size 32 bit random
print(getPrime(32))
def getPrime(bits):
pass
while True:
x = int.from_bytes(os.urandom(int(bits/8)),"little")
if isPrime(x):
return x
def isPrime(number):
if number == 2: