Class: UniversaTools::KeyRing::KeyRecord
- Inherits:
-
Struct
- Object
- Struct
- UniversaTools::KeyRing::KeyRecord
- Defined in:
- lib/universa_tools/keyring.rb
Overview
The record class that hold key, tag and associated information inside the ring
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
-
#key ⇒ Object
Returns the value of attribute key.
-
#tag ⇒ Object
Returns the value of attribute tag.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data
25 26 27 |
# File 'lib/universa_tools/keyring.rb', line 25 def data @data end |
#file_name ⇒ Object
Returns the value of attribute file_name
25 26 27 |
# File 'lib/universa_tools/keyring.rb', line 25 def file_name @file_name end |
#key ⇒ Object
Returns the value of attribute key
25 26 27 |
# File 'lib/universa_tools/keyring.rb', line 25 def key @key end |
#tag ⇒ Object
Returns the value of attribute tag
25 26 27 |
# File 'lib/universa_tools/keyring.rb', line 25 def tag @tag end |
Class Method Details
.load(main_key, file_name) ⇒ Object
30 31 32 33 34 |
# File 'lib/universa_tools/keyring.rb', line 30 def self.load(main_key, file_name) code, tag, packed, data = open(file_name, 'rb') { |f| Boss.load(main_key.etaDecrypt(f.read)) } code != 0 and raise IOError, "unsupported record format #{code}" KeyRecord.new(tag, Universa::PrivateKey.from_packed(packed), data, file_name) end |
Instance Method Details
#save(main_key) ⇒ Object
26 27 28 |
# File 'lib/universa_tools/keyring.rb', line 26 def save(main_key) open(file_name, 'wb') { |f| f << main_key.etaEncrypt(Boss.dump([0, tag, key.pack, data])) } end |