Class: DES::Ctx

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, key) ⇒ Ctx

Returns a new instance of Ctx.



23
24
25
26
27
28
29
30
# File 'lib/des.rb', line 23

def initialize(data, key)
  unless data.is_a?(DES::Block) and key.is_a?(DES::Block)
    raise 'DES::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.



21
22
23
# File 'lib/des.rb', line 21

def data
  @data
end

#keyObject (readonly)

Returns the value of attribute key.



21
22
23
# File 'lib/des.rb', line 21

def key
  @key
end

Instance Method Details

#decryptObject



36
37
38
# File 'lib/des.rb', line 36

def decrypt
  self.run(:decrypt)
end

#encryptObject



32
33
34
# File 'lib/des.rb', line 32

def encrypt
  self.run(:encrypt)
end