Current section

Files

Jump to
feistel_cipher lib feistel_cipher.ex
Raw

lib/feistel_cipher.ex

defmodule FeistelCipher do
@moduledoc false
def table_seed(table) do
<<_::31, key::31, _::450>> = :crypto.hash(:sha512, table)
key
end
def trigger_name(table, source, target) do
"#{table}_encrypt_#{source}_to_#{target}_trigger"
end
def with_defaults(opts) do
opts = Enum.into(opts, %{prefix: default_prefix(), seed: default_seed()})
opts
|> Map.put_new(:create_schema, opts.prefix != default_prefix())
|> Map.put(:quoted_prefix, inspect(opts.prefix))
|> Map.put(:escaped_prefix, String.replace(opts.prefix, "'", "\\'"))
end
def default_prefix do
"public"
end
def default_seed do
1_076_943_109
end
end