using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
namespace VaMKeygen
{
class Program
{
static Dictionary<string, string> scenes = new Dictionary<string, string>();
static void Main(string[] args)
{
string file = System.IO.File.ReadAllText(System.IO.Directory.GetCurrentDirectory() + "\\VaM_Data\\globalgamemanagers", Encoding.UTF8);
MatchCollection matches = Regex.Matches(file, "Assets/VaMAssets/Scenes/Release(.*?)/([FTEC][a-f0-9]{6}).unity");
string version = matches[0].Groups[1].Value;
foreach (Match m in matches)
{
scenes.Add(m.Groups[2].Value, "");
}
for (int i = 0; i < 100000; i++)
{
CheckValue("FreeF", i);
CheckValue("EntertainerE", i);
CheckValue("TeaserT", i);
CheckValue("CreatorC", i);
}
string content = "{";
foreach (KeyValuePair<string, string> s in scenes)
{
content += Environment.NewLine + " \"" + s.Value + "\" : \"true\",";
}
content = content.Substring(0, content.Length - 1);
content += Environment.NewLine + "}";
System.IO.File.WriteAllText(System.IO.Directory.GetCurrentDirectory() + "\\Keys\\" + version + "\\key.json", content);
}
static void CheckValue(string start, int value)
{
SHA256 sha = SHA256.Create();
byte[] bytes;
bytes = sha.ComputeHash(Encoding.UTF8.GetBytes(start + value.ToString("d5")));
string hash = start.Last() + bytes[0].ToString("x2") + bytes[1].ToString("x2") + bytes[2].ToString("x2");
if (scenes.ContainsKey(hash))
{
scenes[hash] = start.Last() + value.ToString("d5");
}
}
}
}