1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Captcha.Native do
6 alias Pleroma.Captcha.Service
13 %{error: :captcha_error}
15 {:ok, answer_data, img_binary} ->
19 url: "data:image/png;base64," <> Base.encode64(img_binary),
20 answer_data: answer_data,
21 seconds_valid: Pleroma.Config.get([Pleroma.Captcha, :seconds_valid])
27 def validate(_token, captcha, captcha) when not is_nil(captcha), do: :ok
28 def validate(_token, _captcha, _answer), do: {:error, :invalid}
32 |> :crypto.strong_rand_bytes()
33 |> Base.url_encode64(padding: false)