Module: ActiveRecord::PGCrypto::SymmetricCoder

Defined in:
lib/active_record/pgcrypto/symmetric_coder.rb

Overview

PGCrypto symmetric encryption/decryption coder for attribute serialization

Class Method Summary collapse

Class Method Details

.decrypted_arel(node) ⇒ Arel::Node

Wraps a node for decryption calls

Returns:

  • (Arel::Node)


50
51
52
53
54
55
56
# File 'lib/active_record/pgcrypto/symmetric_coder.rb', line 50

def self.decrypted_arel(node)
  Arel::Nodes::NamedFunction.new(
    'PGP_SYM_DECRYPT_BYTEA', [
      node, Arel::Nodes::Quoted.new(pgcrypto_key)
    ]
  )
end

.decrypted_arel_text(node) ⇒ Arel::Node

Wraps a node for decryption and text encoded calls

Returns:

  • (Arel::Node)


61
62
63
64
65
66
67
68
# File 'lib/active_record/pgcrypto/symmetric_coder.rb', line 61

def self.decrypted_arel_text(node)
  Arel::Nodes::NamedFunction.new(
    'ENCODE', [
      decrypted_arel(node),
      Arel::Nodes::Quoted.new('escape')
    ]
  )
end

.dump(value) ⇒ String

Encrypts the requested value

Returns:

  • (String)

    binary data



25
26
27
# File 'lib/active_record/pgcrypto/symmetric_coder.rb', line 25

def self.dump(value)
  encrypt(value)
end

.load(value) ⇒ String

Decrypts the requested value

Returns:

  • (String)


18
19
20
# File 'lib/active_record/pgcrypto/symmetric_coder.rb', line 18

def self.load(value)
  decrypt(value)
end