master
E. Almqvist 3 years ago
parent 6730bf4d0f
commit 5f57fd5068
  1. 1
      ma5/rsa/rsa.rb
  2. 4
      ma5/rsa/test.rb

@ -18,6 +18,7 @@ module RSA
end end
end end
@e = enc.sample @e = enc.sample
p enc
@d = RSA.n_inv(@e, @n) @d = RSA.n_inv(@e, @n)
puts "e=#{@e} d=#{@d}" puts "e=#{@e} d=#{@d}"

@ -3,7 +3,7 @@
require_relative "rsa" require_relative "rsa"
Primes = File.read("primes.txt").chomp.split(",").map do |pstr| Primes = File.read("primes.txt").chomp.split(",").map do |pstr|
pstr.to_i p = pstr.to_i
end end
puts "Fetching random primes..." puts "Fetching random primes..."
@ -22,6 +22,6 @@ data.encrypt!(key.pubkey)
puts "Encrypted bytes: #{data.raw}" puts "Encrypted bytes: #{data.raw}"
data.decrypt!(key.privkey) data.decrypt!(key.privkey)
puts data.raw puts "Decrypted bytes: #{data.raw}"
p data.data p data.data

Loading…
Cancel
Save