Class: KStor::Crypto::ArmoredValue

Inherits:
Object
  • Object
show all
Defined in:
lib/kstor/crypto/armored_value.rb

Overview

Wrapper class for an ASCII-armored value.

Direct Known Subclasses

ArmoredHash, PrivateKey, PublicKey

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ KStor::Crypto::ArmoredValue

Create a new ASCII-armored value.

Parameters:

  • value (String)

    ASCII-armored string

See Also:

  • KStor::Crypto::ASCIIArmor#decode
  • KStor::Crypto::ASCIIArmor#encode


16
17
18
# File 'lib/kstor/crypto/armored_value.rb', line 16

def initialize(value)
  @value = value
end

Class Method Details

.from_binary(bin_str) ⇒ KStor::Crypto::ArmoredValue

Create from binary data

Parameters:

  • bin_str (String)

    binary data

Returns:



39
40
41
# File 'lib/kstor/crypto/armored_value.rb', line 39

def self.from_binary(bin_str)
  new(ASCIIArmor.encode(bin_str))
end

Instance Method Details

#to_asciiString Also known as: to_s

Serialize value.

Returns:

  • (String)

    serialized value



23
24
25
# File 'lib/kstor/crypto/armored_value.rb', line 23

def to_ascii
  @value
end

#to_binaryString

Get back original value.

Returns:

  • (String)

    binary data



31
32
33
# File 'lib/kstor/crypto/armored_value.rb', line 31

def to_binary
  ASCIIArmor.decode(@value)
end