defmodule Mix.Tasks.SloanelyButSurely.Gen.PasswordHash do @shortdoc @moduledoc @moduledoc """ Hashes a password for the admin account """ use Boundary, classify_to: SloanelyButSurely.Mix use Mix.Task @impl Mix.Task def run(_args) do password = Mix.shell().prompt("Password: ") password = String.trim_trailing(password) password_confirmation = Mix.shell().prompt("Confirm password: ") password_confirmation = String.trim_trailing(password_confirmation) if password == password_confirmation do hashed = Argon2.hash_pwd_salt(password) Mix.shell().info(hashed) else Mix.shell().error("Passwords do not match") end end end