Class: BB8::Decrypt

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Decrypt

Returns a new instance of Decrypt.



6
7
8
# File 'lib/bb8/decrypt.rb', line 6

def initialize(path)
  @path = path
end

Class Method Details

.call(path) ⇒ Object



2
3
4
# File 'lib/bb8/decrypt.rb', line 2

def self.call(path)
  new(path).call
end

Instance Method Details

#callObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bb8/decrypt.rb', line 10

def call
  cipher.decrypt
  cipher.key = bundle.variables['BB8_SECRET_KEY']
  cipher.iv  = bundle.variables['BB8_SECRET_IV']

  buffer = ""
  File.open(path.gsub('.enc', ''), "wb") do |output|
    File.open(path, "rb") do |input|
      while input.read(4096, buffer)
        output << cipher.update(buffer)
      end
      output << cipher.final
    end
  end
end