Class: Encryption::Symmetric

Inherits:
Object
  • Object
show all
Defined in:
lib/modules/symmetric.rb

Direct Known Subclasses

Encryptor

Instance Method Summary collapse

Constructor Details

#initializeSymmetric

Returns a new instance of Symmetric.



6
7
8
# File 'lib/modules/symmetric.rb', line 6

def initialize
  @configuration = Encryption::Configuration::Symmetric.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



10
11
12
13
14
15
# File 'lib/modules/symmetric.rb', line 10

def method_missing(name, *args, &block)
  if @configuration.respond_to? name
    return @configuration.send(name, *args, &block)
  end
  super
end

Instance Method Details

#decrypt(data) ⇒ Object



27
28
29
30
# File 'lib/modules/symmetric.rb', line 27

def decrypt(data)
  cipher_init(:decipher, :decrypt)
  @decipher.update(data) + @decipher.final
end

#encrypt(data) ⇒ Object



22
23
24
25
# File 'lib/modules/symmetric.rb', line 22

def encrypt(data)
  cipher_init(:cipher, :encrypt)
  @cipher.update(data) + @cipher.final
end

#respond_to?(name, include_all = false) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
20
# File 'lib/modules/symmetric.rb', line 17

def respond_to?(name, include_all = false)
  return true if @configuration.respond_to? name
  super
end