
using System.Text;

namespace Zerolauncher.Defender
{
    class CacheSha
    {
        const string key = "mysecretkey";
        static string? sha_engine;
        static string? sha_main;
        public static int errorCode = 0;

        public static void PutE(string eSha)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < eSha.Length; i++)
            {
                sb.Append((char)(eSha[i] ^ key[i % key.Length]));
            }
            sha_engine = sb.ToString();
        }

        public static string? GetE()
        {
            if (sha_engine == null) { return null; }
            var sb = new StringBuilder();
            for (int i = 0; i < sha_engine.Length; i++)
            {
                sb.Append((char)(sha_engine[i] ^ key[i % key.Length]));
            }
            return sb.ToString();

        }

        public static void PutM(string eSha)
        {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < eSha.Length; i++)
            {
                sb.Append((char)(eSha[i] ^ key[i % key.Length]));
            }
            sha_main = sb.ToString();
        }

        public static string? GetM()
        {
            if (sha_main == null) { return null; }
            var sb = new StringBuilder();
            for (int i = 0; i < sha_main.Length; i++)
            {
                sb.Append((char)(sha_main[i] ^ key[i % key.Length]));
            }
            return sb.ToString();

        }

    }

}
