Class: Enveloperb::EncryptedRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/enveloperb/encrypted_record.rb

Overview

An envelope encrypted record.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(s) ⇒ Object

Create an encrypted record from a serialized form.

Encrypted records can be serialized (using #to_s), and then deserialized by passing them into this constructor.

Parameters:

  • s (String)

    the serialized encrypted record. This must be a ‘BINARY` encoded string.



13
14
15
16
17
18
19
# File 'lib/enveloperb/encrypted_record.rb', line 13

def self.new(s)
  unless s.is_a?(String) && s.encoding == Encoding::BINARY
    raise ArgumentError, "Serialized encrypted record must be a binary string"
  end

  _new(s)
end

Instance Method Details

#to_sString

Serialize an encrypted record into a string.

Returns:

  • (String)

Raises:

  • (RuntimeError)

    if something goes spectacularly wrong with the serialization process.



27
28
29
# File 'lib/enveloperb/encrypted_record.rb', line 27

def to_s
  _serialize
end