一种使用机器的NetBois 名字,产生注册码的方法
content
"using System.Security.Cryptography;
using System.Text;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
//以下是用NetBois名产生一串机器码的代码
MD5CryptoServiceProvider provider1;
byte[] array1;
string text1;
string text2;
byte num1;
byte[] array2;
int num2;
provider1 = new MD5CryptoServiceProvider();
array1 = provider1.ComputeHash(Encoding.Default.GetBytes(Environment.MachineName));
text1 = ""ENTOPYMICROSYSTEMSDEVINIMMUHENDISLIK231456789ACD23456789AEFABGHJKLMNPRSTUVWYZXAHMETALIAKKASHAKANESKICI"";
text2 = string.Empty;
array2 = array1;
for (num2 = 0; (num2 < array2.Length); num2 = (num2 + 1))
{
num1 = array2[num2];
text2 = string.Concat(text2, text1.Substring((num1 % text1.Length), 1));
}
this.txtMachineCode.Text = text2.Substring(0, 10);
//以下是用上面的机器码结合姓名、公司、用户ID和注册类型产生注册码的方法
MemoryStream stream1;
IFormatter formatter1;
byte[] array1;
RC2CryptoServiceProvider provider1;
byte[] array2;
byte[] array3;
byte[] array4;
ICryptoTransform transform1;
CryptoStream stream2;
num1 = 2;
stream1 = new MemoryStream();
formatter1 = new BinaryFormatter();
formatter1.Serialize(stream1, this.txtMachineCode.Text);
formatter1.Serialize(stream1, this.txtUserId.Text);
formatter1.Serialize(stream1, cboLicenseType.SelectedIndex);
formatter1.Serialize(stream1, txtUserName.Text);
formatter1.Serialize(stream1, txtCompany.Text);
formatter1.Serialize(stream1, System.DateTime.Now);
array1 = stream1.ToArray();
provider1 = new RC2CryptoServiceProvider();
provider1.KeySize = 128;
provider1.GenerateKey();
provider1.GenerateIV();
array2 = provider1.IV;
array3 = provider1.Key;
transform1 = provider1.CreateEncryptor();
stream1 = new MemoryStream();
stream2 = new CryptoStream(stream1, transform1, System.Security.Cryptography.CryptoStreamMode.Write);
try
{
stream2.Write(array1, 0, array1.Length);
stream2.FlushFinalBlock();
array4 = stream1.ToArray();
}
finally
{
stream1.Close();
stream2.Close();
}
stream1 = new MemoryStream();
formatter1.Serialize(stream1, array4);
formatter1.Serialize(stream1, array3);
formatter1.Serialize(stream1, array2);
this.txtLicenseCode.Text = Convert.ToBase64String(stream1.ToArray()); "
"using System.Security.Cryptography;
using System.Text;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
//以下是用NetBois名产生一串机器码的代码
MD5CryptoServiceProvider provider1;
byte[] array1;
string text1;
string text2;
byte num1;
byte[] array2;
int num2;
provider1 = new MD5CryptoServiceProvider();
array1 = provider1.ComputeHash(Encoding.Default.GetBytes(Environment.MachineName));
text1 = ""ENTOPYMICROSYSTEMSDEVINIMMUHENDISLIK231456789ACD23456789AEFABGHJKLMNPRSTUVWYZXAHMETALIAKKASHAKANESKICI"";
text2 = string.Empty;
array2 = array1;
for (num2 = 0; (num2 < array2.Length); num2 = (num2 + 1))
{
num1 = array2[num2];
text2 = string.Concat(text2, text1.Substring((num1 % text1.Length), 1));
}
this.txtMachineCode.Text = text2.Substring(0, 10);
//以下是用上面的机器码结合姓名、公司、用户ID和注册类型产生注册码的方法
MemoryStream stream1;
IFormatter formatter1;
byte[] array1;
RC2CryptoServiceProvider provider1;
byte[] array2;
byte[] array3;
byte[] array4;
ICryptoTransform transform1;
CryptoStream stream2;
num1 = 2;
stream1 = new MemoryStream();
formatter1 = new BinaryFormatter();
formatter1.Serialize(stream1, this.txtMachineCode.Text);
formatter1.Serialize(stream1, this.txtUserId.Text);
formatter1.Serialize(stream1, cboLicenseType.SelectedIndex);
formatter1.Serialize(stream1, txtUserName.Text);
formatter1.Serialize(stream1, txtCompany.Text);
formatter1.Serialize(stream1, System.DateTime.Now);
array1 = stream1.ToArray();
provider1 = new RC2CryptoServiceProvider();
provider1.KeySize = 128;
provider1.GenerateKey();
provider1.GenerateIV();
array2 = provider1.IV;
array3 = provider1.Key;
transform1 = provider1.CreateEncryptor();
stream1 = new MemoryStream();
stream2 = new CryptoStream(stream1, transform1, System.Security.Cryptography.CryptoStreamMode.Write);
try
{
stream2.Write(array1, 0, array1.Length);
stream2.FlushFinalBlock();
array4 = stream1.ToArray();
}
finally
{
stream1.Close();
stream2.Close();
}
stream1 = new MemoryStream();
formatter1.Serialize(stream1, array4);
formatter1.Serialize(stream1, array3);
formatter1.Serialize(stream1, array2);
this.txtLicenseCode.Text = Convert.ToBase64String(stream1.ToArray()); "