fork from 1.3

This commit is contained in:
moux23333
2024-01-27 21:06:07 +08:00
commit 22fc0b0848
1507 changed files with 24139 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
namespace FreeSR.Database.Account.Util
{
using FreeSR.Database.Account.Model;
public static class AccountTokenUtil
{
private const int AccountTokenLength = 128;
private const string TokenCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
private static Random s_random;
static AccountTokenUtil()
{
s_random = new Random();
}
public static string Generate()
{
var token = "";
for (int i = 0; i < AccountTokenLength; i++)
{
token += TokenCharacters[s_random.Next(TokenCharacters.Length)];
}
return token;
}
public static bool Verify(AccountModel accountModel, string clientToken)
{
if (accountModel == null)
return false;
return string.Equals(accountModel.Token, clientToken);
}
}
}