Add FingerprintManager

This commit is contained in:
2021-06-03 20:19:42 +02:00
parent 1c6b545e6b
commit adcde19346
14 changed files with 240 additions and 5 deletions

View 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);
}
}

View File

@@ -11,7 +11,7 @@ namespace Akari.Prototype.Server.Utils
{
public IPAddressAttribute() : base("Must be a valid IP address")
{
}
public override bool IsValid(object value)

View 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);
}
}
}