clacks/lib/clacks_web/plug/digest.ex

10 lines
268 B
Elixir
Raw Normal View History

2019-10-01 22:39:17 +00:00
defmodule ClacksWeb.Plug.Digest do
alias Plug.Conn
def read_body(conn, opts) do
{:ok, body, conn} = Conn.read_body(conn, opts)
digest = "SHA-256=" <> Base.encode64(:crypto.hash(:sha256, body))
{:ok, body, Conn.assign(conn, :digest, digest)}
end
end