Class: Virgil::SDK::Cryptography::Keys::StorageItem

Inherits:
Struct
  • Object
show all
Defined in:
lib/virgil/sdk/cryptography/keys/storage_item.rb

Overview

StorageItem class represents a key pair storage entry.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dataCrypto::Bytes

key pair in bytes

Returns:

  • (Crypto::Bytes)

    the current value of data



45
46
47
# File 'lib/virgil/sdk/cryptography/keys/storage_item.rb', line 45

def data
  @data
end

#metaHash

the meta data associated with key pair.

Returns:

  • (Hash)

    the current value of meta



45
46
47
# File 'lib/virgil/sdk/cryptography/keys/storage_item.rb', line 45

def meta
  @meta
end

#nameString

Gets or sets the name.

Returns:

  • (String)

    the current value of name



45
46
47
# File 'lib/virgil/sdk/cryptography/keys/storage_item.rb', line 45

def name
  @name
end

Class Method Details

.restore_from_json(name, str_json) ⇒ Object



56
57
58
59
# File 'lib/virgil/sdk/cryptography/keys/storage_item.rb', line 56

def self.restore_from_json(name, str_json)
  model = JSON.parse(str_json)
  new(name, HighLevel::VirgilBuffer.from_base64(model['data']).bytes, model['meta'])
end

Instance Method Details

#to_jsonObject



47
48
49
50
51
52
53
# File 'lib/virgil/sdk/cryptography/keys/storage_item.rb', line 47

def to_json
  model = {
      'data': HighLevel::VirgilBuffer.new(data).to_base64,
      'meta': meta
  }
  model.to_json
end