class MobileSecrets::FileHandler

Public Class Methods

new(password) click to toggle source
# File lib/src/file_handler.rb, line 6
def initialize password
  @password = password
end

Public Instance Methods

encrypt(file) click to toggle source
# File lib/src/file_handler.rb, line 10
def encrypt file
  file_content = File.read file
  cipher = OpenSSL::Cipher::AES256.new :CBC
  cipher.encrypt
  iv = cipher.random_iv
  cipher.key = @password
  cipher_text = iv + cipher.update(file_content) + cipher.final
  cipher_text
end