Class: Virgil::SDK::HighLevel::VirgilCardManager::CardArray
- Inherits:
-
Array
- Object
- Array
- Virgil::SDK::HighLevel::VirgilCardManager::CardArray
- Defined in:
- lib/virgil/sdk/high_level/virgil_card_manager.rb
Instance Attribute Summary collapse
-
#crypto ⇒ Object
Returns the value of attribute crypto.
Instance Method Summary collapse
-
#encrypt(buffer) ⇒ VirgilBuffer
Encrypts the specified data using recipients Public keys.
-
#initialize(array) ⇒ CardArray
constructor
A new instance of CardArray.
Constructor Details
#initialize(array) ⇒ CardArray
Returns a new instance of CardArray
78 79 80 81 |
# File 'lib/virgil/sdk/high_level/virgil_card_manager.rb', line 78 def initialize(array) @crypto = Cryptography::VirgilCrypto.new super end |
Instance Attribute Details
#crypto ⇒ Object
Returns the value of attribute crypto
76 77 78 |
# File 'lib/virgil/sdk/high_level/virgil_card_manager.rb', line 76 def crypto @crypto end |
Instance Method Details
#encrypt(buffer) ⇒ VirgilBuffer
Encrypts the specified data using recipients Public keys.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/virgil/sdk/high_level/virgil_card_manager.rb', line 98 def encrypt(buffer) all_public_keys = self.map(&:public_key) buffer_to_encrypt = case buffer.class.name.split("::").last when 'VirgilBuffer' buffer when 'String' VirgilBuffer.from_string(buffer) when 'Array' VirgilBuffer.from_bytes(buffer) else raise ArgumentError.new("Buffer has unsupported type") end VirgilBuffer.new(crypto.encrypt(buffer_to_encrypt.bytes, *all_public_keys)) end |