module EDB::Cryptography

Public Class Methods

decrypt(method, filename) click to toggle source
# File lib/edb/cryptography.rb, line 46
def decrypt(method, filename)
  ::EDB::Logger.log(:info, "Decrypting #{filename}...")

  data = File.open(filename, 'rb') do |file|
    ciphered_data = file.read

    this_module = to_module(method)
    data        = this_module.decrypt(ciphered_data)
  end

  File.open("#{filename}.dec", 'wb') do |file|
    file.write(data)
  end
end
encrypt(method, filename) click to toggle source
# File lib/edb/cryptography.rb, line 31
def encrypt(method, filename)
  ::EDB::Logger.log(:info, "Encrypting #{filename}...")

  ciphered_data = File.open(filename, 'rb') do |file|
    data = file.read

    this_module   = to_module(method)
    ciphered_data = this_module.encrypt(data)
  end

  File.open(filename, 'wb') do |file|
    file.write(ciphered_data)
  end
end

Private Class Methods

to_module(method) click to toggle source
# File lib/edb/cryptography.rb, line 62
def to_module(method)
  Object.const_get("::EDB::Cryptography::#{method}")
end