9d6bbb0854f3b42601c15bd480b691f4c3586267
[akkoma] / lib / pleroma / plugs / digest.ex
1 defmodule Pleroma.Web.Plugs.DigestPlug do
2 alias Plug.Conn
3 require Logger
4
5 def read_body(conn, opts) do
6 {:ok, body, conn} = Conn.read_body(conn, opts)
7 digest = "SHA-256=" <> (:crypto.hash(:sha256, body) |> Base.encode64())
8 {:ok, body, Conn.assign(conn, :digest, digest)}
9 end
10 end