Add FingerprintManager
This commit is contained in:
15
Akari.Prototype.Server/Utils/AkariPath.cs
Normal file
15
Akari.Prototype.Server/Utils/AkariPath.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Akari.Prototype.Server.Utils
|
||||
{
|
||||
public static class AkariPath
|
||||
{
|
||||
public const string BasePath = "Data";
|
||||
|
||||
public static string GetPath(string path) => Path.Combine(BasePath, path);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace Akari.Prototype.Server.Utils
|
||||
{
|
||||
public IPAddressAttribute() : base("Must be a valid IP address")
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override bool IsValid(object value)
|
||||
|
||||
35
Akari.Prototype.Server/Utils/Security.cs
Normal file
35
Akari.Prototype.Server/Utils/Security.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Isopoh.Cryptography.Argon2;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Akari.Prototype.Server.Utils
|
||||
{
|
||||
public static class Security
|
||||
{
|
||||
public const int HashLength = 32;
|
||||
public const int SaltLength = 12;
|
||||
|
||||
public static string Argon2idHash(byte[] password)
|
||||
{
|
||||
var salt = new byte[8];
|
||||
|
||||
RandomNumberGenerator.Fill(salt);
|
||||
|
||||
var config = new Argon2Config()
|
||||
{
|
||||
HashLength = 32,
|
||||
Lanes = Environment.ProcessorCount / 2,
|
||||
Threads = Environment.ProcessorCount / 2,
|
||||
Password = password,
|
||||
Salt = salt,
|
||||
Type = Argon2Type.HybridAddressing,
|
||||
Version = Argon2Version.Nineteen
|
||||
};
|
||||
|
||||
return Argon2.Hash(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user