Class: Chamber::Filters::DecryptionFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/chamber/filters/decryption_filter.rb

Constant Summary collapse

BASE64_STRING_PATTERN =
%r{\A[A-Za-z0-9\+/]{342}==\z}
LARGE_DATA_STRING_PATTERN =
%r{
  \A                            # Beginning of String
  (
    [A-Za-z0-9\+\/#]*\={0,2}    # Base64 Encoded Key
  )
  \#                            # Separator
  (
    [A-Za-z0-9\+\/#]*\={0,2}    # Base64 Encoded IV
  )
  \#                            # Separator
  (
    [A-Za-z0-9\+\/#]*\={0,2}    # Base64 Encoded Data
  )
  \z                            # End of String
}x

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ DecryptionFilter

Returns a new instance of DecryptionFilter.



36
37
38
39
40
# File 'lib/chamber/filters/decryption_filter.rb', line 36

def initialize(options = {})
  self.decryption_keys  = options.fetch(:decryption_keys, {}) || {}
  self.data             = options.fetch(:data).dup
  self.secure_key_token = /\A#{Regexp.escape(options.fetch(:secure_key_prefix))}/
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



32
33
34
# File 'lib/chamber/filters/decryption_filter.rb', line 32

def data
  @data
end

#decryption_keysObject

Returns the value of attribute decryption_keys.



34
35
36
# File 'lib/chamber/filters/decryption_filter.rb', line 34

def decryption_keys
  @decryption_keys
end

#secure_key_tokenObject

Returns the value of attribute secure_key_token.



32
33
34
# File 'lib/chamber/filters/decryption_filter.rb', line 32

def secure_key_token
  @secure_key_token
end

Class Method Details

.execute(options = {}) ⇒ Object



42
43
44
# File 'lib/chamber/filters/decryption_filter.rb', line 42

def self.execute(options = {})
  new(options).__send__(:execute)
end