logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

digest.ex (457B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.Plugs.DigestPlug do
  5. alias Plug.Conn
  6. require Logger
  7. def read_body(conn, opts) do
  8. {:ok, body, conn} = Conn.read_body(conn, opts)
  9. digest = "SHA-256=" <> (:crypto.hash(:sha256, body) |> Base.encode64())
  10. {:ok, body, Conn.assign(conn, :digest, digest)}
  11. end
  12. end