using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace DevexpressPatchKeygen
{
    internal static class SingletonParserList
    {
        // Method to compute authentication by comparing two byte arrays
        [MethodImpl(MethodImplOptions.NoInlining)]
        public static List<int> ComputeAuthentication(this byte[] array1, byte[] array2)
        {
            List<int> list = new List<int>();

            // Ensure both arrays are not null and have data
            if (array1 == null || array1.Length == 0 || array2 == null || array2.Length == 0)
            {
                return list;
            }

            // Iterate over the first byte array
            for (int i = 0; i < array1.Length; i++)
            {
                bool match = true;

                // Iterate over the second byte array
                for (int j = 0; j < array2.Length; j++)
                {
                    // Compare byte by byte
                    if (i + j >= array1.Length || array1[i + j] != array2[j])
                    {
                        match = false;
                        break;
                    }
                }

                // If a match is found, add the starting index to the list
                if (match)
                {
                    list.Add(i);
                }
            }
            return list;
        }
    }
}
