Class: SimpleCrypt::Secret
- Inherits:
-
Object
- Object
- SimpleCrypt::Secret
- Defined in:
- lib/simple_crypt/secret.rb
Instance Attribute Summary collapse
-
#auth_data ⇒ Object
Returns the value of attribute auth_data.
-
#auth_tag ⇒ Object
Returns the value of attribute auth_tag.
-
#iv ⇒ Object
Returns the value of attribute iv.
-
#salt ⇒ Object
Returns the value of attribute salt.
-
#secret_data ⇒ Object
Returns the value of attribute secret_data.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(secret_data = nil, iv = nil, salt = nil, auth_tag = nil, auth_data = nil) ⇒ Secret
constructor
A new instance of Secret.
- #to_json ⇒ Object
Constructor Details
#initialize(secret_data = nil, iv = nil, salt = nil, auth_tag = nil, auth_data = nil) ⇒ Secret
Returns a new instance of Secret.
8 9 10 11 12 13 14 |
# File 'lib/simple_crypt/secret.rb', line 8 def initialize(secret_data = nil, iv = nil, salt = nil, auth_tag = nil, auth_data = nil) @secret_data = secret_data @iv = iv @salt = salt @auth_tag = auth_tag @auth_data = auth_data end |
Instance Attribute Details
#auth_data ⇒ Object
Returns the value of attribute auth_data.
6 7 8 |
# File 'lib/simple_crypt/secret.rb', line 6 def auth_data @auth_data end |
#auth_tag ⇒ Object
Returns the value of attribute auth_tag.
6 7 8 |
# File 'lib/simple_crypt/secret.rb', line 6 def auth_tag @auth_tag end |
#iv ⇒ Object
Returns the value of attribute iv.
6 7 8 |
# File 'lib/simple_crypt/secret.rb', line 6 def iv @iv end |
#salt ⇒ Object
Returns the value of attribute salt.
6 7 8 |
# File 'lib/simple_crypt/secret.rb', line 6 def salt @salt end |
#secret_data ⇒ Object
Returns the value of attribute secret_data.
6 7 8 |
# File 'lib/simple_crypt/secret.rb', line 6 def secret_data @secret_data end |
Class Method Details
.load(json) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/simple_crypt/secret.rb', line 20 def self.load(json) data = JSON.parse(json) s = new( data['@secret_data'], data['@iv'], data['@salt'], data['@auth_tag'], data['@auth_data'] ) s end |
Instance Method Details
#to_json ⇒ Object
16 17 18 |
# File 'lib/simple_crypt/secret.rb', line 16 def to_json JSON.generate(Hash[instance_variables.map { |name| [name, instance_variable_get(name)] }]) end |