Class: RubyDES::Ctx

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-des.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, key) ⇒ Ctx

Returns a new instance of Ctx.



30
31
32
33
34
35
36
37
# File 'lib/ruby-des.rb', line 30

def initialize(data, key)
  unless data.is_a?(RubyDES::Block) and key.is_a?(RubyDES::Block)
    raise "RubyDES::InvalidBlockFormat: Data and key must be a Block object."
  end
  
  @data = data
  @key  = key
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



28
29
30
# File 'lib/ruby-des.rb', line 28

def data
  @data
end

#keyObject (readonly)

Returns the value of attribute key.



28
29
30
# File 'lib/ruby-des.rb', line 28

def key
  @key
end

Instance Method Details

#decryptObject



43
44
45
# File 'lib/ruby-des.rb', line 43

def decrypt
  self.run(:decrypt)
end

#encryptObject



39
40
41
# File 'lib/ruby-des.rb', line 39

def encrypt
  self.run(:encrypt)
end