C#实现简单的加密防止拷贝复制软件

本文介绍如何使用C#语言实现简单的软件加密,以防止内容被拷贝和复制。主要内容包括主页面代码的加密实现以及注册加密代码和注册机代码的编写,旨在提升软件的安全性。
摘要由CSDN通过智能技术生成

主页面代码


using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Management;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Client
{
   
    public partial class Form_Test : Form
    {
   
        private string encryptComputer = string.Empty;
        private bool isRegist = false;
        private const int timeCount = 30;
        public Form_Test()
        {
   
            InitializeComponent();
        }

        private void Form_Test_Load(object sender, EventArgs e)
        {
   
            //加载
            string computer = GetComputerInfo();
            encryptComputer = new EncryptionHelper().EncryptString(computer);
            if (CheckRegist() == true)
            {
   
                lbRegistInfo.Text = "已注册";
            }
            else
            {
   
                lbRegistInfo.Text = "待注册,运行十分钟后将自动关闭!";
                RegistFileHelper.WriteComputerInfoFile(encryptComputer);
                TryRunForm();
            }



        }
        /// <summary>
        /// 试运行窗口
        /// </summary>
        private void TryRunForm()
        {
   
            Thread threadClose = new Thread(CloseForm);
            threadClose.IsBackground = true;
            threadClose.Start();
        }
        private bool CheckRegist()
        {
   
            EncryptionHelper helper = new EncryptionHelper();
            string md5key = helper.GetMD5String(encryptComputer);
            return CheckRegistData(md5key);
        }
        private bool CheckRegistData(string key)
        {
   
            if (RegistFileHelper.ExistRegistInfofile() == false)
            {
   
                isRegist = false;
                return false;
            }
            else
            {
   
                string info = RegistFileHelper.ReadRegistFile();
                var helper = new EncryptionHelper(EncryptionKeyEnum.KeyB);
                string registData = helper.DecryptString(info);
                if (key == registData)
                {
   
                    isRegist = true;
                    return true;
                }
                else
                {
   
                    isRegist = false;
                    return false;
                }
            }
        }
        private void CloseForm()
        {
   
            int count = 0;
            while (count < timeCount && isRegist == false)
            {
   
                if (isRegist == true)
                {
   
                    return;
                }
                Thread.Sleep(1 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

试行

祝您生活愉快!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值