Module: CarrierWave::SecureFile::AESFile
- Included in:
- AESFileDecrypt, AESFileEncrypt, AESFileKeygen
- Defined in:
- lib/carrierwave/securefile/aes_file.rb
Instance Attribute Summary collapse
-
#cipher ⇒ Object
Returns the value of attribute cipher.
-
#cipher_type ⇒ Object
Returns the value of attribute cipher_type.
-
#iv ⇒ Object
Returns the value of attribute iv.
-
#key ⇒ Object
Returns the value of attribute key.
Instance Method Summary collapse
- #init_cipher(the_cipher) ⇒ Object
- #initialize(module_name) ⇒ Object
- #set_cipher_iv(the_cipher_iv = nil) ⇒ Object
- #set_cipher_key(the_cipher_key = nil) ⇒ Object
- #set_cipher_method(the_cipher_method) ⇒ Object
Instance Attribute Details
#cipher ⇒ Object
Returns the value of attribute cipher.
25 26 27 |
# File 'lib/carrierwave/securefile/aes_file.rb', line 25 def cipher @cipher end |
#cipher_type ⇒ Object
Returns the value of attribute cipher_type.
25 26 27 |
# File 'lib/carrierwave/securefile/aes_file.rb', line 25 def cipher_type @cipher_type end |
#iv ⇒ Object
Returns the value of attribute iv.
25 26 27 |
# File 'lib/carrierwave/securefile/aes_file.rb', line 25 def iv @iv end |
#key ⇒ Object
Returns the value of attribute key.
25 26 27 |
# File 'lib/carrierwave/securefile/aes_file.rb', line 25 def key @key end |
Instance Method Details
#init_cipher(the_cipher) ⇒ Object
27 28 29 30 31 |
# File 'lib/carrierwave/securefile/aes_file.rb', line 27 def init_cipher(the_cipher) unless self.cipher self.cipher = OpenSSL::Cipher.new(the_cipher) end end |
#initialize(module_name) ⇒ Object
59 60 61 62 |
# File 'lib/carrierwave/securefile/aes_file.rb', line 59 def initialize(module_name) require module_name eval("#{module_name}.init") end |
#set_cipher_iv(the_cipher_iv = nil) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/carrierwave/securefile/aes_file.rb', line 49 def set_cipher_iv(the_cipher_iv=nil) if self.iv self.cipher.iv = self.iv elsif the_cipher_iv.nil? self.cipher.iv = self.iv = self.cipher.random_key else self.cipher.iv = self.iv = the_cipher_iv end end |
#set_cipher_key(the_cipher_key = nil) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/carrierwave/securefile/aes_file.rb', line 39 def set_cipher_key(the_cipher_key=nil) if self.key self.cipher.key = self.key elsif the_cipher_key.nil? self.cipher.key = self.key = self.cipher.random_key else self.cipher.key = self.key = the_cipher_key end end |
#set_cipher_method(the_cipher_method) ⇒ Object
33 34 35 36 37 |
# File 'lib/carrierwave/securefile/aes_file.rb', line 33 def set_cipher_method(the_cipher_method) if [:encrypt, :decrypt].include? the_cipher_method.to_sym self.cipher.send(the_cipher_method) end end |