up
This commit is contained in:
		
							
								
								
									
										23
									
								
								src/StellaOps.Cryptography/PasswordHashAlgorithms.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								src/StellaOps.Cryptography/PasswordHashAlgorithms.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
using System;
 | 
			
		||||
 | 
			
		||||
namespace StellaOps.Cryptography;
 | 
			
		||||
 | 
			
		||||
/// <summary>
 | 
			
		||||
/// Well-known identifiers for password hashing algorithms supported by StellaOps.
 | 
			
		||||
/// </summary>
 | 
			
		||||
public static class PasswordHashAlgorithms
 | 
			
		||||
{
 | 
			
		||||
    public const string Argon2id = "argon2id";
 | 
			
		||||
    public const string Pbkdf2Sha256 = "pbkdf2-sha256";
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Converts the enum value into the canonical algorithm identifier string.
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static string ToAlgorithmId(this PasswordHashAlgorithm algorithm) =>
 | 
			
		||||
        algorithm switch
 | 
			
		||||
        {
 | 
			
		||||
            PasswordHashAlgorithm.Argon2id => Argon2id,
 | 
			
		||||
            PasswordHashAlgorithm.Pbkdf2 => Pbkdf2Sha256,
 | 
			
		||||
            _ => throw new ArgumentOutOfRangeException(nameof(algorithm), algorithm, "Unsupported password hash algorithm.")
 | 
			
		||||
        };
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user