Class: RSA::Private
- Inherits:
-
Object
- Object
- RSA::Private
- Defined in:
- lib/rsa.rb
Instance Attribute Summary collapse
-
#key_d ⇒ Object
readonly
Returns the value of attribute key_d.
-
#key_p ⇒ Object
readonly
Returns the value of attribute key_p.
-
#key_q ⇒ Object
readonly
Returns the value of attribute key_q.
-
#totiente_n ⇒ Object
readonly
Returns the value of attribute totiente_n.
Instance Method Summary collapse
- #create_file(archive) ⇒ Object
- #create_file_of_keys ⇒ Object
- #generated_d(e) ⇒ Object
-
#initialize ⇒ Private
constructor
A new instance of Private.
Constructor Details
#initialize ⇒ Private
Returns a new instance of Private.
58 59 60 61 |
# File 'lib/rsa.rb', line 58 def initialize generated_p_and_q generated_totiente_n end |
Instance Attribute Details
#key_d ⇒ Object (readonly)
Returns the value of attribute key_d.
56 57 58 |
# File 'lib/rsa.rb', line 56 def key_d @key_d end |
#key_p ⇒ Object (readonly)
Returns the value of attribute key_p.
56 57 58 |
# File 'lib/rsa.rb', line 56 def key_p @key_p end |
#key_q ⇒ Object (readonly)
Returns the value of attribute key_q.
56 57 58 |
# File 'lib/rsa.rb', line 56 def key_q @key_q end |
#totiente_n ⇒ Object (readonly)
Returns the value of attribute totiente_n.
56 57 58 |
# File 'lib/rsa.rb', line 56 def totiente_n @totiente_n end |
Instance Method Details
#create_file(archive) ⇒ Object
77 78 79 80 |
# File 'lib/rsa.rb', line 77 def create_file(archive) key_n = @key_p * @key_q archive.write [key_n, @key_d] end |
#create_file_of_keys ⇒ Object
72 73 74 75 |
# File 'lib/rsa.rb', line 72 def create_file_of_keys private_key_file = ArchivePrivate.new private_key_file.write keys end |
#generated_d(e) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/rsa.rb', line 63 def generated_d(e) number = 1 until Mathematics.is_multiplicative_inverse?((number * e), @totiente_n) number += 1 end @key_d = number end |