# `AshAuthentication.BcryptProvider`
[🔗](https://github.com/team-alembic/ash_authentication/blob/main/lib/ash_authentication/bcrypt_provider.ex#L5)

Provides the default implementation of `AshAuthentication.HashProvider` using `Bcrypt`.

# `hash`

```elixir
@spec hash(String.t()) :: {:ok, String.t()} | :error
```

Given some user input as a string, convert it into it's hashed form using `Bcrypt`.

## Example

    iex> {:ok, hashed} = hash("Marty McFly")
    ...> String.starts_with?(hashed, "$2b$04$")
    true

# `simulate`

```elixir
@spec simulate() :: false
```

Simulate a password check to help avoid timing attacks.

## Example

    iex> simulate()
    false

# `valid?`

```elixir
@spec valid?(input :: String.t() | nil, hash :: String.t()) :: boolean()
```

Check if the user input matches the hash.

## Example

    iex> valid?("Marty McFly", "$2b$04$qgacrnrAJz8aPwaVQiGJn.PvryldV.NfOSYYvF/CZAGgMvvzhIE7S")
    true

---

*Consult [api-reference.md](api-reference.md) for complete listing*
