加密程序总结(C#)

总体思路

首先获取到每台电脑的cpuid和memoryid在加上日期形成每台机器独一无二的机器码,在验证过程中,获取当前计算机的时间加上我们设置的两百天的授权日期,与当前机器的当前日期作比较,如果在授权期内,启动VR康复训练exe文件,否者不执行exe文件。

方法及控件

在这里插入图片描述

Form1

初始化控件

GetCpuID

获取cpu的Id

GetMemoryID()

获取存储器id

CreatMachineCode

生成机器码

CreatKey

生成验证Key值

VerifyKey

DateTime d1 = DateTime.Parse(VerifyDate.Substring(0, VerifyDate.Length - 2)); //要确保parse转换的字符串格式正确,否则出错
DateTime d2 = d1.AddDays(Convert.ToInt32(AddDays));
DateTime d3 = DateTime.Now;

判断当前电脑是否还在授权期内

if (d2 > d3)
{
    MessageBox.Show("授权期限内");
    this.Close();
    return true;
}
if (d2 < d3)
{
    MessageBox.Show("授权过期");
    this.Close();
    return false;
}

EncryptDES

编码加密

DecryptDES

解密

判断方法

授权期内在txt文本存入true,在授权期外存入false

//判断是否在授权期限内
bool t = VerifyKey(CreatMachineCode());
System.IO.File.WriteAllText(@"C:\\Users\\twj83\\Desktop\\WindowsFormsApplication2\\WindowsFormsApplication2\\1.txt", t + "\r\n");

在program文件在读入txt文本,true则调用exe文件。

//从txt中获取t的值
bool t;
using (TextReader reader = File.OpenText(@"C:\\Users\\twj83\\Desktop\\WindowsFormsApplication2\\WindowsFormsApplication2\\1.txt"))
{
    t = bool.Parse(reader.ReadLine());
}
if (t == true)
{
    Process.Start(@"C:\\Users\\twj83\\Desktop\\VRnew\\VRnew\\VRnew\\bin\\Release\\VRnew.exe");
}

界面

在这里插入图片描述
破解窍门:
调整电脑日期,我猜的,一点都不安全哈哈

发布了35 篇原创文章 · 获赞 2 · 访问量 943

猜你喜欢

转载自blog.csdn.net/y18771025420/article/details/103898087