Sha256: 735608233a72528e7c7e1f77c6511fb4f298f74142db6b1308b2704b0cc862fd
Contents?: true
Size: 1.74 KB
Versions: 24
Compression:
Stored size: 1.74 KB
Contents
# encoding: utf-8 module Backup module Encryptor class OpenSSL < Base ## # The password that'll be used to encrypt the backup. This # password will be required to decrypt the backup later on. attr_accessor :password ## # Determines whether the 'base64' should be used or not attr_writer :base64 ## # Determines whether the 'salt' flag should be used attr_writer :salt ## # Creates a new instance of Backup::Encryptor::OpenSSL and # sets the password attribute to what was provided def initialize(&block) load_defaults! @base64 ||= false @salt ||= false instance_eval(&block) if block_given? end ## # Performs the encryption of the backup file 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 private ## # Backup::Encryptor::OpenSSL uses the 256bit AES encryption cipher. # 256bit AES is what the US Government uses to encrypt information at the "Top Secret" level. def options (['aes-256-cbc'] + base64 + salt).join("\s") end ## # Returns '-a' if @base64 is set to 'true'. # This option will make the encrypted output base64 encoded, # this makes the encrypted file readable using text editors def base64 return ['-base64'] if @base64; [] end ## # Returns '-salt' if @salt is set to 'true'. # This options adds strength to the encryption def salt return ['-salt'] if @salt; [] end end end end
Version data entries
24 entries across 24 versions & 3 rubygems