module Lorj::SSLCrypt
SSL Encryption feature for Lorj
.
Public Class Methods
encrypt_value(value, entr)
click to toggle source
Function to encrypt a data with a entr key.
return:
-
value : encrypted value in
Base64
encoded data.
# File lib/core/core_setup_encrypt.rb, line 85 def self.encrypt_value(value, entr) Base64.strict_encode64( Encryptor.encrypt( :value => value, :key => entr[:key], :iv => Base64.strict_decode64(entr[:iv]), :salt => entr[:salt] ) ) end
get_encrypted_value(enc_value, entr, sDesc)
click to toggle source
internal runtime function for process call #_build_hdata and #_get_encrypted_value_hidden Get encrypted value
parameters:
- +default+ : encrypted default value - +entropy+ : Entropy Hash - +sDesc+ : data description
return:
-
value : decrypted value.
raise:
# File lib/core/core_setup_encrypt.rb, line 64 def self.get_encrypted_value(enc_value, entr, sDesc) return '' if enc_value.nil? begin Encryptor.decrypt( :value => Base64.strict_decode64(enc_value), :key => entr[:key], :iv => Base64.strict_decode64(entr[:iv]), :salt => entr[:salt] ) rescue => e PrcLib.error("Unable to decrypt your %s.\n"\ "%s\n"\ ' You will need to re-enter it.', sDesc, e) end end
new_encrypt_key(key = rand(36**10).to_s(36))
click to toggle source
internal runtime function to create a new key parameters:
- +new+ : true to create a new key.
return:
- entropy: Hash. Entropy data used as key to encrypt values. Details from encryptor's gem. - :key: password - :salt : String current time number - :iv: Base64 random iv
# File lib/core/core_setup_encrypt.rb, line 41 def self.new_encrypt_key(key = rand(36**10).to_s(36)) random_iv = OpenSSL::Cipher::Cipher.new('aes-256-cbc').random_iv { :key => key, :salt => Time.now.to_i.to_s, :iv => Base64.strict_encode64(random_iv) } end