Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
Marcin Woźniak 2020-11-10 13:46:10 +01:00
parent 521369834c
commit c9a960a36f
Signed by: y0rune
GPG Key ID: F204C385F57EB348
1 changed files with 5 additions and 6 deletions

View File

@ -5,8 +5,6 @@
# Marcin Woźniak # Marcin Woźniak
# s434812 # s434812
# #
# Last edit: 09-11-2020
#
##################################### #####################################
require 'openssl' require 'openssl'
@ -35,7 +33,7 @@ def random_gen_Zn(n,k)
end end
while true do while true do
r = SecureRandom.random_number(max) r = SecureRandom.random_number(min..max)
if r < n then if r < n then
break break
end end
@ -107,9 +105,10 @@ def primalityTest(n)
return true return true
end end
counter = rand(3..n) counter = 1000
#counter = SecureRandom.random_number(3..n)
while (counter != 0) do while (counter != 0) do
b = rand(2..n-2) # Tez dziala n-1 b = SecureRandom.random_number(2..n-2) # Tez dziala n-1
if betterExponentiation(b,n-1,n) != 1 then if betterExponentiation(b,n-1,n) != 1 then
return false return false
end end
@ -192,6 +191,6 @@ puts "Zadanie 5: " + squareRootFp(15485863,2).inspect
# Gdzie n - liczba wejsciowa # Gdzie n - liczba wejsciowa
puts "Zadanie 6: " + primalityTest(13).inspect puts "Zadanie 6: " + primalityTest(13).inspect
puts "Zadanie 6: " + primalityTest(14).inspect puts "Zadanie 6: " + primalityTest(1000000016531).inspect
################################################################################### ###################################################################################