=== Summary: 675 files | 7 generated | 484 fresh | 4605 untracked | 4268 adopted | 355 marked | 466 validated-ok | 2+0 stale (sig+body) | 0 skipped | 0 failed | elapsed 11:08:11.442 (40091.44s) ===

This commit is contained in:
julian
2026-06-28 02:50:05 -07:00
parent a19fb90902
commit 586f02a2ca
654 changed files with 5260 additions and 0 deletions
+6
View File
@@ -9,6 +9,7 @@ namespace adas_core.Domain.Utils;
/// <summary>
/// Provides a static container for cryptographic operations and utilities related to the Adas domain.
/// </summary>
/// <!-- aidoc:v1 sig=2c4859b -->
public static class CryptoAdas
{
private static readonly Regex PassRegex = new("^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$");
@@ -19,6 +20,7 @@ public static class CryptoAdas
/// </summary>
/// <param name="input">The string to hash. Its ASCII byte representation is used as the input to the MD5 algorithm.</param>
/// <returns>The MD5 hash of <paramref name="input"/> formatted as an uppercase hexadecimal string.</returns>
/// <!-- aidoc:v1 sig=e509d6c body=5733afd -->
public static string CreateMd5(string input)
{
using var md5 = MD5.Create();
@@ -39,6 +41,7 @@ public static class CryptoAdas
/// <param name="gF">The grouped field whose names, max, since, regularity, and results are included in the hash input.</param>
/// <param name="patientId">The identifier of the patient whose data is being hashed.</param>
/// <returns>An MD5 hash string representing the combined patient and grouped field data.</returns>
/// <!-- aidoc:v1 sig=0805f4d body=4e67e9c -->
public static string CreateMd5GroupedObs(GroupedField gF, ObjectId patientId)
{
var names = CollectionsUtils.IfEmptyOrNull(gF.Names, [gF.Name ?? string.Empty]);
@@ -56,6 +59,7 @@ public static class CryptoAdas
/// </summary>
/// <param name="input">The plain text string to be hashed.</param>
/// <returns>A BCrypt hashed representation of the input string.</returns>
/// <!-- aidoc:v1 sig=095e787 body=667d6d0 -->
public static string CreateBCrypt(string input)
{
return BCrypt.Net.BCrypt.HashPassword(input);
@@ -67,6 +71,7 @@ public static class CryptoAdas
/// <param name="loginPass">The plain text password entered by the user during login.</param>
/// <param name="passwordHash">The stored BCrypt hash to compare the password against.</param>
/// <returns><c>true</c> if the password matches the hash; otherwise, <c>false</c>.</returns>
/// <!-- aidoc:v1 sig=a06bd55 body=9f08488 -->
public static bool VerifyPassword(string loginPass, string passwordHash)
{
return BCrypt.Net.BCrypt.Verify(loginPass, passwordHash);
@@ -77,6 +82,7 @@ public static class CryptoAdas
/// </summary>
/// <param name="password">The password string to evaluate against the strong password requirements.</param>
/// <returns><c>true</c> if the password matches the strong password pattern; otherwise, <c>false</c>.</returns>
/// <!-- aidoc:v1 sig=fc43cf7 body=9a130ab -->
public static bool IsStrongPassword(string password)
{
return PassRegex.IsMatch(password);