using Microsoft.AspNetCore.Mvc; using Hasher; using Models; using System.IdentityModel.Tokens.Jwt; using System.Security.Claims; using System.Text; using Microsoft.IdentityModel.Tokens; namespace backend.Controllers { /// /// For generating Argon2d hashes in test. Do not use in prod or with front end /// [Route("api/pwhash")] [ApiController] public class PasswordHashController : ControllerBase { private readonly IConfiguration _config; private readonly ILogger _logger; public PasswordHashController(IConfiguration config, ILogger logger) { _config = config; _logger = logger; } /// /// Takes a plaintext password in the form {"password": "yourpasswordhere"}, /// generates an Argon2d hash for it (using random salt), and returns the hash /// [HttpPost] public ActionResult HashPassword([FromBody] dynamic plainTextPassword) { string password = (string) plainTextPassword.password; string hashedPW = Argon2dHasher.GenerateArgon2Hash(password, null); return Ok($"Password hash: '{hashedPW}'"); } } }