Class: Webhookdb::Crypto::Boxed

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw, b64) ⇒ Boxed

Returns a new instance of Boxed.



49
50
51
52
# File 'lib/webhookdb/crypto.rb', line 49

def initialize(raw, b64)
  @raw = raw
  @b64 = b64
end

Class Method Details

.from_b64(b64str) ⇒ Object

Raises:

  • (ArgumentError)


44
45
46
47
# File 'lib/webhookdb/crypto.rb', line 44

def self.from_b64(b64str)
  raise ArgumentError, "base64 string cannot be nil" if b64str.nil?
  return self.new(nil, b64str)
end

.from_raw(bytestr) ⇒ Object

Raises:

  • (ArgumentError)


39
40
41
42
# File 'lib/webhookdb/crypto.rb', line 39

def self.from_raw(bytestr)
  raise ArgumentError, "bytes string cannot be nil" if bytestr.nil?
  return self.new(bytestr, nil)
end

Instance Method Details

#base64String

Returns:

  • (String)


55
56
57
58
# File 'lib/webhookdb/crypto.rb', line 55

def base64
  @b64 ||= Base64.urlsafe_encode64(@raw)
  return @b64
end

#rawString

Returns:

  • (String)


61
62
63
64
# File 'lib/webhookdb/crypto.rb', line 61

def raw
  @raw ||= Base64.urlsafe_decode64(@b64)
  return @raw
end