Class: Backup::Encryptor::OpenSSL

Inherits:
Base
  • Object
show all
Defined in:
lib/backup/encryptor/open_ssl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#log!

Methods included from Configuration::Helpers

#clear_defaults!, #getter_methods, #load_defaults!, #setter_methods

Methods included from CLI

#mkdir, #rm, #run, #utility

Constructor Details

#initialize(&block) ⇒ OpenSSL

Creates a new instance of Backup::Encryptor::OpenSSL and sets the password attribute to what was provided



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

def initialize(&block)
  load_defaults!

  @base64 ||= false
  @salt   ||= false

  instance_eval(&block) if block_given?
end

Instance Attribute Details

#base64=(value) ⇒ Object

Determines whether the ‘base64’ should be used or not



14
15
16
# File 'lib/backup/encryptor/open_ssl.rb', line 14

def base64=(value)
  @base64 = value
end

#passwordObject

The password that’ll be used to encrypt the backup. This password will be required to decrypt the backup later on.



10
11
12
# File 'lib/backup/encryptor/open_ssl.rb', line 10

def password
  @password
end

#salt=(value) ⇒ Object

Determines whether the ‘salt’ flag should be used



18
19
20
# File 'lib/backup/encryptor/open_ssl.rb', line 18

def salt=(value)
  @salt = value
end

Instance Method Details

#perform!Object

Performs the encryption of the backup file



34
35
36
37
38
39
# File 'lib/backup/encryptor/open_ssl.rb', line 34

def perform!
  log!
  run("#{ utility(:openssl) } #{ options } -in '#{ Backup::Model.file }' -out '#{ Backup::Model.file }.enc' -k '#{ password }'")
  rm(Backup::Model.file)
  Backup::Model.extension += '.enc'
end