Changes between Version 22 and Version 23 of P9


Ignore:
Timestamp:
06/23/26 00:06:22 (4 days ago)
Author:
211099
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • P9

    v22 v23  
    847847    : "RegularUser";
    848848}}}
     849== Password Security
     850Passwords must never be stored as plaintext in the database. Instead, ChapterX uses BCrypt to hash every password before it is saved.
     851BCrypt is configured with a default work factor of 11 rounds, which makes brute-force attacks computationally expensive:
     852{{{
     853var user = new Domain.Entities.User
     854{
     855    Username = request.Username,
     856    Email    = request.Email,
     857    Password = BCrypt.Net.BCrypt.HashPassword(request.Password),
     858    ...
     859};
     860}}}
     861At login, the submitted password is verified against the stored hash without ever reconstructing the original:
     862{{{
     863if (!BCrypt.Net.BCrypt.Verify(request.Password, user.Password))
     864    throw new UnauthorizedAccessException("Invalid email or password.");
     865}}}