コード例 #1
0
        private string EncryptMYKEYID(string ValidationKey)
        {
            DateTime now    = DateTime.Now;
            string   strTgl = string.Empty;
            string   cpuID  = string.Empty;

            if (ValidationKey == string.Empty)
            {
                try
                {
                    GetInfo cpuInfo = new GetInfo();

                    cpuID = cpuInfo.GetCPUId();
                }
                catch
                {
                    MessageBox.Show("Error Get Encryption Keys", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return("");
                }
            }

            strTgl = now.Year.ToString("0000") + now.Month.ToString("00") + now.Day.ToString("00");

            System.Text.StringBuilder strEncrypt = new System.Text.StringBuilder();
            char myCodeDecrypt;

            int[] SecretCode = new int[] { 7, 10, 5, 14, 20, 3, 11, 9, 25 };

            string strResult = string.Empty;

            for (int i = 0, idxPjg = strTgl.Length, idxCode = 0, pjgIdxCode = 9; i < idxPjg; i++)
            {
                myCodeDecrypt = (char)((int)((char)strTgl[i]) + SecretCode[idxCode++]);
                if (idxCode >= pjgIdxCode)
                {
                    idxCode = 0;
                }

                strEncrypt.Append(myCodeDecrypt);
            }

            for (int i = 0, idxPjg = cpuID.Length, idxCode = 0, pjgIdxCode = 9; i < idxPjg; i++)
            {
                myCodeDecrypt = (char)((int)((char)cpuID[i]) + SecretCode[idxCode++]);
                if (idxCode >= pjgIdxCode)
                {
                    idxCode = 0;
                }

                strEncrypt.Append(myCodeDecrypt);
            }

            strResult = strEncrypt.ToString();
            return(strResult);
        }