add a bunch of authentication stuff
This commit is contained in:
parent
996e59f49a
commit
aca83fa1ef
22 changed files with 681 additions and 28 deletions
23
Foxchat.Core/Utils/ConvertUtils.cs
Normal file
23
Foxchat.Core/Utils/ConvertUtils.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using System.Security.Cryptography;
|
||||
|
||||
namespace Foxchat.Core.Utils;
|
||||
|
||||
public static class CryptoUtils
|
||||
{
|
||||
public static bool TryFromBase64String(string b64, out byte[] bytes)
|
||||
{
|
||||
try
|
||||
{
|
||||
bytes = Convert.FromBase64String(b64);
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
bytes = [];
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static string RandomToken(int bytes = 48) =>
|
||||
Convert.ToBase64String(RandomNumberGenerator.GetBytes(bytes)).Trim('=');
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue