Created
December 1, 2015 00:22
-
-
Save aburgd/79c03a1534633882ba58 to your computer and use it in GitHub Desktop.
publicKey class method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Diffie | |
p defined?(Diffie) | |
def publicKey(base, modPrime, aSecret) | |
@publicKey = 0 | |
# puts "Enter your shared prime (g): " | |
# base = Integer(gets.chomp) | |
# puts "Enter your second prime (p): " | |
# modPrime = Integer(gets.chomp) | |
# puts "Enter your secret prime (a): " | |
# aSecret = Integer(gets.chomp) | |
@publicKey = base ** aSecret % modPrime | |
print "Share this with your contact: " + publicKey | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby DHKE.rb | |
"constant" | |
Are you computing the public key or the shared secret? | |
public key | |
"constant" | |
Enter your shared prime (g): | |
7 | |
Enter your second prime (p): | |
5 | |
Enter your secret prime (a): | |
2 | |
DHKE.rb:17:in `<main>': undefined method `publicKey' for nil:NilClass (NoMethodError) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment