KRzA/4-lab/alice.rb
Marcin Woźniak 17237eab0a
Updated
Signed-off-by: Marcin Woźniak <y0rune@aol.com>
2020-12-03 21:21:19 +01:00

38 lines
595 B
Ruby
Executable File

#!/usr/bin/ruby
#####################################
#
# Marcin Woźniak
# s434812
#
#####################################
require 'socket'
load 'modul1.rb'
sock = TCPSocket.new("localhost",3000)
puts sock.gets
spec=specyficPrimaryNumber
p,q = spec[0], spec[1]
g = generator(p,q)
x = SecureRandom.random_number(2..p-2)
y = betterExponentiation(g,x,p)
privKey = [p, q, y]
pubKey = [p, x]
puts "privKey(p,q,y): " + privKey.inspect
puts "pubKey(p,x): " + pubKey.inspect
puts
puts p.inspect.unpack('b*')
puts
sock.puts p.inspect.unpack("b*")
sock.puts x.inspect.unpack("b*")
sock.close