Exemple #1
0
        internal static byte[] CalculateSecretHash(byte[] Modulus, byte[] Exponent)
        {
            lock (CalculationLock)
            {
                SortedList <byte, int> NumCounter = new SortedList <byte, int>();
                for (int i = 0; i < Modulus.Length; i++)
                {
                    if (!NumCounter.ContainsKey(Modulus[i]))
                    {
                        NumCounter.Add(Modulus[i], 1);
                    }
                    else
                    {
                        NumCounter[Modulus[i]] = (NumCounter[Modulus[i]] + 1) * ((Exponent[i % Exponent.Length] + 3));
                    }
                }

                PayloadWriter pw = new PayloadWriter();
                for (int i = 0; i < NumCounter.Count; i++)
                {
                    long val = NumCounter.Keys[i] + (Modulus[(i * 3) % Modulus.Length] ^ (NumCounter.Keys[i] + NumCounter.Values[i]));
                    pw.WriteDouble(Math.Pow(val, 8));
                }

                SHA512Managed ShaHasher = new SHA512Managed();
                return(ShaHasher.ComputeHash(pw.ToByteArray()));
            }
        }