using Google.FlatBuffers;
using System.Data.SQLite;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SCHALE.Common.Crypto.XXHash;
using SCHALE.Common.FlatData;
using System.Reflection;
using System.Text;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
namespace SCHALE.Common.Crypto
{
public static class TableService
{
///
/// General password gen by file name, encode to base64 for zips password
///
///
///
///
public static byte[] CreatePassword(string key, int length = 20)
{
byte[] password = GC.AllocateUninitializedArray((int)Math.Round((decimal)(length / 4 * 3)));
using var xxhash = XXHash32.Create();
xxhash.ComputeHash(Encoding.UTF8.GetBytes(key));
var mt = new MersenneTwister((int)xxhash.HashUInt32);
int i = 0;
while (i < password.Length)
{
Array.Copy(BitConverter.GetBytes(mt.Next()), 0, password, i, Math.Min(4, password.Length - i));
i += 4;
}
return password;
}
#if DEBUG
public static List