Sha256: 7d5523189960d2e1c4b1f8110beb765bf9d238086de0bd0976811d32e985b2d3
Contents?: true
Size: 1.03 KB
Versions: 2
Compression:
Stored size: 1.03 KB
Contents
require 'crypt_keeper/log_subscriber/postgres_pgp' module CryptKeeper module Provider class PostgresPgp include CryptKeeper::Helper::SQL attr_accessor :key attr_accessor :pgcrypto_options # Public: Initializes the encryptor # # options - A hash, :key is required def initialize(options = {}) ActiveSupport.run_load_hooks(:crypt_keeper_posgres_pgp_log, self) @key = options.fetch(:key) do raise ArgumentError, "Missing :key" end @pgcrypto_options = options.fetch(:pgcrypto_options, '') end # Public: Encrypts a string # # Returns an encrypted string def encrypt(value) escape_and_execute_sql(["SELECT pgp_sym_encrypt(?, ?, ?)", value.to_s, key, pgcrypto_options])['pgp_sym_encrypt'] end # Public: Decrypts a string # # Returns a plaintext string def decrypt(value) escape_and_execute_sql(["SELECT pgp_sym_decrypt(?, ?)", value, key])['pgp_sym_decrypt'] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
crypt_keeper-0.13.1 | lib/crypt_keeper/provider/postgres_pgp.rb |
crypt_keeper-0.13.0 | lib/crypt_keeper/provider/postgres_pgp.rb |