10 lines
268 B
Elixir
10 lines
268 B
Elixir
|
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
|