Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            string licenseCode = FileHelper.Decrypt(FileHelper.ReadTextFile("License.dat"), LicenseHelper.GetCpuId().Substring(0, 8));

            richTextBox3.Text = licenseCode;

            LicenseHelper.GetPubKey();
            if (true == LicenseHelper.CheckLicense(licenseCode.Substring(10, licenseCode.Length - 10), LicenseHelper.GetCpuId()))
            {
                MessageBox.Show("正确");
            }
            else
            {
                MessageBox.Show("errro");
            }
        }
Example #2
0
        private void btnLinceseCheck_Click(object sender, EventArgs e)
        {
            string licenseInfo = txtBoxLicense.Text;

            if (licenseInfo.Length < 30)
            {
                licenseInfo       = FileHelper.Decrypt(licenseInfo);
                richTextBox2.Text = licenseInfo;
            }
            else
            {
                licenseInfo       = FileHelper.Decrypt(licenseInfo, textBoxGuid.Text.Substring(0, 8));
                richTextBox2.Text = licenseInfo;
            }

            string date    = licenseInfo.Substring(0, 10);
            string license = licenseInfo.Substring(10, licenseInfo.Length - 10);

            if (string.IsNullOrEmpty(license))
            {
                if (date == "0000-00-00")
                {
                    MessageBox.Show(string.Format("验证通过, 有效期为:{0}", "永久有效"), "提示信息", MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show(string.Format("验证通过, 有效期为:{0}", date), "提示信息", MessageBoxButtons.OK);
                }
            }
            else
            {
                LicenseHelper.GetPubKey();
                if (true == LicenseHelper.CheckLicense(license, textBoxGuid.Text))
                {
                    MessageBox.Show(string.Format("验证通过, 有效期为:{0}", date), "提示信息", MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show("验证失败");
                }
            }
        }