Update
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
parent
521369834c
commit
c9a960a36f
@ -5,8 +5,6 @@
|
||||
# Marcin Woźniak
|
||||
# s434812
|
||||
#
|
||||
# Last edit: 09-11-2020
|
||||
#
|
||||
#####################################
|
||||
|
||||
require 'openssl'
|
||||
@ -35,7 +33,7 @@ def random_gen_Zn(n,k)
|
||||
end
|
||||
|
||||
while true do
|
||||
r = SecureRandom.random_number(max)
|
||||
r = SecureRandom.random_number(min..max)
|
||||
if r < n then
|
||||
break
|
||||
end
|
||||
@ -107,9 +105,10 @@ def primalityTest(n)
|
||||
return true
|
||||
end
|
||||
|
||||
counter = rand(3..n)
|
||||
counter = 1000
|
||||
#counter = SecureRandom.random_number(3..n)
|
||||
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
|
||||
return false
|
||||
end
|
||||
@ -192,6 +191,6 @@ puts "Zadanie 5: " + squareRootFp(15485863,2).inspect
|
||||
# Gdzie n - liczba wejsciowa
|
||||
|
||||
puts "Zadanie 6: " + primalityTest(13).inspect
|
||||
puts "Zadanie 6: " + primalityTest(14).inspect
|
||||
puts "Zadanie 6: " + primalityTest(1000000016531).inspect
|
||||
|
||||
###################################################################################
|
||||
|
Loading…
Reference in New Issue
Block a user