mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 11:11:10 +00:00
Implements authentication system
This commit is contained in:
1 parent
38829d64ff
commit
a6dcf65d1c
103 files changed
+2983
-454
No files matched your search
@@ -0,0 +1,27 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Infrastructure.Security;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the service for cryptographic concerns.
|
||||
/// </summary>
|
||||
public interface ICryptographyService
|
||||
{
|
||||
/// <summary>
|
||||
/// Encrypts a plaintext string using AES encryption with a randomly generated initialization vector (IV).
|
||||
/// </summary>
|
||||
/// <param name="plaintext">The plaintext string to encrypt.</param>
|
||||
/// <returns>A Base64-encoded string of the combined IV and encrypted ciphertext.</returns>
|
||||
/// <exception cref="ArgumentException">Thrown when <paramref name="plaintext"/> is <see langword="null"/> or empty.</exception>
|
||||
string Encrypt(string plaintext);
|
||||
|
||||
/// <summary>
|
||||
/// Decrypts a Base64-encoded string that contains both the IV and ciphertext.
|
||||
/// </summary>
|
||||
/// <param name="ciphertext">The Base64-encoded string containing both IV and ciphertext.</param>
|
||||
/// <returns>The decrypted plaintext string.</returns>
|
||||
/// <exception cref="ArgumentException">Thrown when <paramref name="ciphertext"/> is <see langword="null"/>, empty, or invalid.</exception>
|
||||
string Decrypt(string ciphertext);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace Lumina.Application.Common.Infrastructure.Security;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the service for hashing passwords.
|
||||
/// </summary>
|
||||
public interface IHashService
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a hash from a string.
|
||||
/// </summary>
|
||||
/// <param name="password">The string to be hashed.</param>
|
||||
/// <returns>The hashed string.</returns>
|
||||
string HashString(string password);
|
||||
|
||||
/// <summary>
|
||||
/// Verifies a password against a hash.
|
||||
/// </summary>
|
||||
/// <param name="password">The string to be checked.</param>
|
||||
/// <param name="hashedPassword">The hashed representation of the string to be checked.</param>
|
||||
/// <returns><see langword="true"/> if <paramref name="password"/> and the de-hashed versions of <paramref name="hashedPassword"/> are equal, <see langword="false"/> otherwise.</returns>
|
||||
bool CheckStringAgainstHash(string password, string hashedPassword);
|
||||
}
|
||||
Reference in new issue
Block a user