Class: MobileSecrets::FileHandler
- Inherits:
-
Object
- Object
- MobileSecrets::FileHandler
- Defined in:
- lib/src/file_handler.rb
Instance Method Summary collapse
- #encrypt(file) ⇒ Object
-
#initialize(password) ⇒ FileHandler
constructor
A new instance of FileHandler.
Constructor Details
#initialize(password) ⇒ FileHandler
Returns a new instance of FileHandler.
6 7 8 |
# File 'lib/src/file_handler.rb', line 6 def initialize password @password = password end |
Instance Method Details
#encrypt(file) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# 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 |