Init enter game

This commit is contained in:
Naruse
2025-06-14 11:15:32 +08:00
commit 6a03b39f07
568 changed files with 92872 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
using System.Security.Cryptography;
using System.Text;
namespace KianaBH.Util.Security;
public class Crypto
{
private static readonly Random SecureRandom = new();
// Simple way to create a unique session key
public static string CreateSessionKey(string accountUid)
{
var random = new byte[64];
SecureRandom.NextBytes(random);
var temp = accountUid + "." + DateTime.Now.Ticks + "." + SecureRandom;
try
{
var bytes = SHA512.HashData(Encoding.UTF8.GetBytes(temp));
return Convert.ToBase64String(bytes);
}
catch
{
var bytes = SHA512.HashData(Encoding.UTF8.GetBytes(temp));
return Convert.ToBase64String(bytes);
}
}
}