class EncryptData::Convert
Public Class Methods
new(key = nil)
click to toggle source
# File lib/encrypt_data.rb, line 11 def initialize(key = nil) @key = key unless key.nil? end
Public Instance Methods
dump(value)
click to toggle source
# File lib/encrypt_data.rb, line 26 def dump(value) begin Base64.encode64( Crypt.encrypt( Marshal.dump(value), @key)) rescue Exception => e puts "\e[31m#{e.message}\e[0m" end end
load(value)
click to toggle source
# File lib/encrypt_data.rb, line 15 def load(value) begin return if value.nil? Marshal.load( Crypt.decrypt( Base64.decode64(value), @key)) rescue Exception => e puts "\e[31m#{e.message}\e[0m" end end