<commit_before>defmodule Phoenix.Token do
  @moduledoc """
  Tokens provide a way to generate and verify bearer
  tokens for use in Channels or API authentication.

  The data can be read by clients, but the message is
  signed to prevent tampering.

  ## Example

  When generating a unique token for usage in an API or Channel
  it is advised to use a unique identifier for the user typically
  the id from a database. For example:

      iex> user_id = 1
      iex> token = Phoenix.Token.sign(MyApp.Endpoint, "user", user_id)
      iex> Phoenix.Token.verify(MyApp.Endpoint, "user", token)
      {:ok, 1}

  In that example we have a user's id, we generate a token and
  verify it using the secret key base configured in the given
  `endpoint`.

  The first argument to both `sign/4` and `verify/4` can be one of:

      * the module name of a Phoenix endpoint (shown above) - where
        the secret key base is extracted from the endpoint
      * `Plug.Conn` - where the secret key base is extracted from the
        endpoint stored in the connection
      * `Phoenix.Socket` - where the secret key base is extracted from
        the endpoint stored in the socket
      * a string, representing the secret key base itself. We recommend
        a key base with at least 20 characters to provide enough entropy

  ## Usage

  Once a token is signed, we can send it to the client in multiple ways.

  One is via the meta tag:

      <%= tag :meta, name: "channel_token",
                     content: Phoenix.Token.sign(@conn, "user", @current_user.id) %>

  Or an endpoint that returns it:<commit_msg>Doc: fix indentation of bullet list in token.ex<commit_after>defmodule Phoenix.Token do
  @moduledoc """
  Tokens provide a way to generate and verify bearer
  tokens for use in Channels or API authentication.

  The data can be read by clients, but the message is
  signed to prevent tampering.

  ## Example

  When generating a unique token for usage in an API or Channel
  it is advised to use a unique identifier for the user typically
  the id from a database. For example:

      iex> user_id = 1
      iex> token = Phoenix.Token.sign(MyApp.Endpoint, "user", user_id)
      iex> Phoenix.Token.verify(MyApp.Endpoint, "user", token)
      {:ok, 1}

  In that example we have a user's id, we generate a token and
  verify it using the secret key base configured in the given
  `endpoint`.

  The first argument to both `sign/4` and `verify/4` can be one of:

    * the module name of a Phoenix endpoint (shown above) - where
      the secret key base is extracted from the endpoint
    * `Plug.Conn` - where the secret key base is extracted from the
      endpoint stored in the connection
    * `Phoenix.Socket` - where the secret key base is extracted from
      the endpoint stored in the socket
    * a string, representing the secret key base itself. We recommend
      a key base with at least 20 characters to provide enough entropy

  ## Usage

  Once a token is signed, we can send it to the client in multiple ways.

  One is via the meta tag:

      <%= tag :meta, name: "channel_token",
                     content: Phoenix.Token.sign(@conn, "user", @current_user.id) %>

  Or an endpoint that returns it:
{'fraction_non_alphanumeric': 0.06261624302541847, 'fraction_numerical': 0.0037197768133911966, 'mean_word_length': 2.9210206561360876, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4512726', 'n_tokens_mistral': 904, 'n_tokens_neox': 851, 'n_words': 458}