Class: Rgc::Clean

Inherits:
Object
  • Object
show all
Includes:
KeyFile
Defined in:
lib/rgc/clean.rb

Instance Method Summary collapse

Methods included from KeyFile

#load_key

Constructor Details

#initialize(global_options, options, args) ⇒ Clean

Returns a new instance of Clean.



5
6
7
8
9
# File 'lib/rgc/clean.rb', line 5

def initialize(global_options, options, args)
  load_key

  print(encrypt(ARGF.read))
end

Instance Method Details

#encrypt(content) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/rgc/clean.rb', line 11

def encrypt(content)
  @aes = OpenSSL::Cipher.new("AES-128-CBC")
  @aes.encrypt
  @aes.key = @key
  # TODO: consinder to set @aes.iv

  Base64.encode64(@aes.update(content) + @aes.final)
end