Sha256: 2db4f6da8da49ebc6662b0e772130800a65a2247dbda5a67f9040a4989618584
Contents?: true
Size: 866 Bytes
Versions: 6
Compression:
Stored size: 866 Bytes
Contents
module SymmetricEncryption module ActiveRecord class EncryptedAttribute < ::ActiveModel::Type::String def initialize(random_iv: true, compress: false, type: :string) @random_iv = random_iv @compress = compress @encrypted_type = type end def deserialize(value) return if value.nil? SymmetricEncryption.decrypt(value, type: encrypted_type) end def serialize(value) return if value.nil? SymmetricEncryption.encrypt( value, type: encrypted_type, compress: compress, random_iv: random_iv ) end private # Symmetric Encryption uses coercible gem to handle casting def cast_value(value) value end attr_reader :random_iv, :compress, :encrypted_type end end end
Version data entries
6 entries across 6 versions & 1 rubygems