apoc v1.0.0-rc1 Apoc.Adapter.MAC behaviour View Source
Defines a Message Authenticated Code adapter.
defmodule MyMac do
use Apoc.Adapter.MAC
@impl Apoc.Adapter.MAC
def sign(message, key, opts \ []) do
tag = signing_algo(message, key)
{:ok, tag}
end
# ...
end Link to this section Summary
Callbacks
Signs a message by generating a tag with the given key.
Will return a type of the form {:ok, tag} if successful
or :error otherwise.
Similar to sign/3 except that is returns the tag directly
and raises Apoc.Error in the case of an error.
Link to this section Types
Link to this section Callbacks
Specs
Signs a message by generating a tag with the given key.
Will return a type of the form {:ok, tag} if successful
or :error otherwise.
Specs
Similar to sign/3 except that is returns the tag directly
and raises Apoc.Error in the case of an error.
Specs
Verifies a message based on a tag generated by sign/3
(or sign!/3). Returns true or false.
Example
if MyMac.verify(tag, message, key) do
do_something(message)
end