Class: EverSdk::Crypto::BoxEncryptionAlgorithm
- Inherits:
-
Object
- Object
- EverSdk::Crypto::BoxEncryptionAlgorithm
- Defined in:
- lib/ever_sdk_client/crypto.rb
Constant Summary collapse
- TYPES =
%i[cha_cha20 nacl_box nacl_secret_box]
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type:, **args) ⇒ BoxEncryptionAlgorithm
constructor
A new instance of BoxEncryptionAlgorithm.
- #to_h ⇒ Object
Constructor Details
#initialize(type:, **args) ⇒ BoxEncryptionAlgorithm
Returns a new instance of BoxEncryptionAlgorithm.
282 283 284 285 286 287 288 |
# File 'lib/ever_sdk_client/crypto.rb', line 282 def initialize(type:, **args) unless TYPES.include?(type) raise ArgumentError.new("type #{type} is unknown; known types: #{TYPES}") end @type = type @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
280 281 282 |
# File 'lib/ever_sdk_client/crypto.rb', line 280 def args @args end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
280 281 282 |
# File 'lib/ever_sdk_client/crypto.rb', line 280 def type @type end |
Instance Method Details
#to_h ⇒ Object
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/ever_sdk_client/crypto.rb', line 290 def to_h hash = case type when :cha_cha20 { nonce: args[:nonce] } when :nacl_box { their_public: args[:their_public], nonce: args[:nonce] } when :nacl_secret_box { nonce: args[:nonce] } end { type: Helper.sym_to_capitalized_case_str(type) }.merge(hash) end |