Class: CarrierWave::SecureFile::AESFileDecrypt
- Inherits:
-
Object
- Object
- CarrierWave::SecureFile::AESFileDecrypt
- Includes:
- AESFile
- Defined in:
- lib/carrierwave/securefile/aes_file.rb
Instance Attribute Summary
Attributes included from AESFile
#cipher, #cipher_type, #iv, #key
Instance Method Summary collapse
- #do(from_file, to_file) ⇒ Object
-
#initialize(key, iv) ⇒ AESFileDecrypt
constructor
A new instance of AESFileDecrypt.
Methods included from AESFile
#init_cipher, #set_cipher_iv, #set_cipher_key, #set_cipher_method
Constructor Details
#initialize(key, iv) ⇒ AESFileDecrypt
Returns a new instance of AESFileDecrypt.
111 112 113 114 115 116 117 |
# File 'lib/carrierwave/securefile/aes_file.rb', line 111 def initialize(key, iv) self.cipher_type = 'aes-256-cbc' init_cipher self.cipher_type set_cipher_method :decrypt set_cipher_key key set_cipher_iv iv end |
Instance Method Details
#do(from_file, to_file) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/carrierwave/securefile/aes_file.rb', line 119 def do(from_file, to_file) buf = "" File.open(to_file, "wb") do |outf| File.open(from_file, "rb") do |inf| while inf.read(4096, buf) outf << self.cipher.update(buf) end outf << self.cipher.final end end end |