module Eco::Data::Crypto
TODO study how to encrypt uniquely the api key in the configuration file TODO study how RSA could boost team-shared Drive folder (updates, and people files should be encrypted via public key)
Constants
- MY_NAME
- PARSER_FILE
- PATH
- THIS_FILENAME
file conf definitions
- WORKING_DIR
Public Class Methods
decrypt(encrypted_data)
click to toggle source
# File lib/eco/data/crypto/encryption.rb, line 292 def self.decrypt (encrypted_data) unless encrypted_data && encrypted_data.key && encrypted_data.iv return nil end cipher = OpenSSL::Cipher.new('aes-256-cbc') cipher.decrypt cipher.key = encrypted_data.key cipher.iv = encrypted_data.iv str_c = encrypted_data.content str = "" while str_c.length > 0 str += cipher.update(str_c.slice!(0, 4096)) #puts str[-50..-1] || str end str += cipher.final return str end
encrypt(str)
click to toggle source
# File lib/eco/data/crypto/encryption.rb, line 278 def self.encrypt (str) cipher = OpenSSL::Cipher.new('aes-256-cbc') cipher.encrypt key = cipher.random_key iv = cipher.random_iv str_c = "" while str.length > 0 str_c += cipher.update(str.slice!(0, 4096)) end str_c += cipher.final EncryptedData.new({content: str_c, key: key, iv: iv}) end