Module: EDB::Cryptography
- Extended by:
- IsModuleSupported
- Defined in:
- lib/edb/cryptography.rb,
lib/edb/cryptography/aes_256_cbc.rb
Defined Under Namespace
Modules: AES_256_CBC
Class Method Summary collapse
Methods included from IsModuleSupported
Class Method Details
.decrypt(method, filename) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# 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) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# 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 |