C#写了一个简单的注册机制 每次生成的注册码都一样 求解
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Management;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
Random rd = new Random();
int num1 = rd.Next(100000, 999999);
int num2 = rd.Next(100000, 999999);
textBox1.Text = "" + num1 + getCpu() + num2;
string apppath = Environment.CurrentDirectory;
string path = apppath + @"\key.txt";
string str;
StreamReader sr = new StreamReader(path, false);
try
{
str = sr.ReadLine().ToString();
sr.Close();
this.textBox2.Text = str;///读取
}
catch
{
sr.Close();
}
// textBox2.Text = line;
}
public string getCpu()
{
string strCpu = null;
ManagementClass myCpu = new ManagementClass("win32_Processor");
ManagementObjectCollection myCpuConnection = myCpu.GetInstances();
foreach (ManagementObject myObject in myCpuConnection)
{
strCpu = myObject.Properties["Processorid"].Value.ToString();
break;
}
return strCpu;
}
private void button1_Click(object sender, EventArgs e)
{
string str1 = textBox1.Text.Substring(6, 16);
var md5 = new MD5CryptoServiceProvider();
string t2 = BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(str1)), 4, 8);
t2 = t2.Replace("-", "");
if (textBox2.Text == t2)
{
StreamWriter sw = new StreamWriter("key.txt", false);
sw.Write(textBox2.Text);
sw.Flush();
sw.Close();
Form1 f1 = new Form1();
f1.Show();
this.Hide();
}
else
{
if (textBox2.Text != "")
{
MessageBox.Show("注册码错误!");
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Management;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
Random rd = new Random();
int num1 = rd.Next(100000, 999999);
int num2 = rd.Next(100000, 999999);
textBox1.Text = "" + num1 + getCpu() + num2;
string apppath = Environment.CurrentDirectory;
string path = apppath + @"\key.txt";
string str;
StreamReader sr = new StreamReader(path, false);
try
{
str = sr.ReadLine().ToString();
sr.Close();
this.textBox2.Text = str;///读取
}
catch
{
sr.Close();
}
// textBox2.Text = line;
}
public string getCpu()
{
string strCpu = null;
ManagementClass myCpu = new ManagementClass("win32_Processor");
ManagementObjectCollection myCpuConnection = myCpu.GetInstances();
foreach (ManagementObject myObject in myCpuConnection)
{
strCpu = myObject.Properties["Processorid"].Value.ToString();
break;
}
return strCpu;
}
private void button1_Click(object sender, EventArgs e)
{
string str1 = textBox1.Text.Substring(6, 16);
var md5 = new MD5CryptoServiceProvider();
string t2 = BitConverter.ToString(md5.ComputeHash(Encoding.Default.GetBytes(str1)), 4, 8);
t2 = t2.Replace("-", "");
if (textBox2.Text == t2)
{
StreamWriter sw = new StreamWriter("key.txt", false);
sw.Write(textBox2.Text);
sw.Flush();
sw.Close();
Form1 f1 = new Form1();
f1.Show();
this.Hide();
}
else
{
if (textBox2.Text != "")
{
MessageBox.Show("注册码错误!");
}
}
...全文
相关推荐
C# 软件 机器码生成注册码
这时,使用注册码和激活码机制就显得至关重要。本文将详细介绍如何使用C#语言实现机器码生成及注册码功能,以确保软件仅能在授权的硬件环境中运行。首先,我们来了解什么是机器码。
C# 注册码注册机制 实例源码(加密解密)
开发者可能在注册码生成时计算一个哈希值,然后在验证时对比用户的输入与服务器保存的哈希值是否一致,从而判断注册码是否有效。最后,网络通信是注册码验证环节不可或缺的一部分。
注册码生成器
在IT行业中,软件授权是确保知识产权的重要手段,而“注册码生成器”是这个领域中的一个关键工具。本文将深入探讨使用C#编程语言创建注册码生成器的相关知识点,包括其工作原理、实现方法以及安全考量。
c# --注册码生成算法
本篇文章将详细解析一个基于C#实现的注册码生成算法,该算法通过获取计算机的CPU序列号和硬盘序列号来生成唯一且特定于每台机器的注册码。
基于C#实现简单离线注册码生成与验证
"该资源介绍如何使用C#语言实现一个简单的离线注册码系统,通过RSA加密技术和Base64编码生成注册码,并在客户端进行验证。核心思想是服务端持有可能的私钥,利用RSA算法对客户端的标识(如MAC地


