示例#1
0
        private void GeneratePokeStrings(string hashStr)
        {
            //Also check file name just in case
            if (FileName.Contains("pm"))
            {
                string baseName    = Path.GetFileNameWithoutExtension(FileName);
                string pokeStrFile = hashStr.Replace("pm0000_00", baseName);

                ulong hash = FNV64A1.CalculateSuffix(pokeStrFile);
                if (!hashList.ContainsKey(hash))
                {
                    hashList.Add(hash, pokeStrFile);
                }
            }

            for (int i = 0; i < 1000; i++)
            {
                string pokeStr = hashStr.Replace("pm0000", $"pm{i.ToString("D4")}");

                ulong hash = FNV64A1.CalculateSuffix(pokeStr);
                if (!hashList.ContainsKey(hash))
                {
                    hashList.Add(hash, pokeStr);
                }
            }
        }
示例#2
0
        private void GenerateHashList()
        {
            foreach (string hashStr in Properties.Resources.Pkmn.Split('\n'))
            {
                string HashString = hashStr.TrimEnd();

                ulong hash = FNV64A1.CalculateSuffix(HashString);
                if (!hashList.ContainsKey(hash))
                {
                    hashList.Add(hash, HashString);
                }

                if (HashString.Contains("pm0000"))
                {
                    GeneratePokeStrings(HashString);
                }

                string[] hashPaths = HashString.Split('/');
                for (int i = 0; i < hashPaths?.Length; i++)
                {
                    hash = FNV64A1.CalculateSuffix(hashPaths[i]);
                    if (!hashList.ContainsKey(hash))
                    {
                        hashList.Add(hash, HashString);
                    }
                }
            }
        }
 public static ulong CalculateHash(string type, string text)
 {
     if (type == "NLG_Hash")
     {
         return(StringToHash(text));
     }
     else if (type == "FNV64A1")
     {
         return(FNV64A1.CalculateSuffix(text));
     }
     else if (type == "CRC32")
     {
         return(Toolbox.Library.Security.Cryptography.Crc32.Compute(text));
     }
     return(0);
 }