我的c#注册码操作类
来源:互联网 发布:反驳父母 知乎 编辑:程序博客网 时间:2024/06/05 22:59
1类库:
2使用方法
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Security.Cryptography;
namespace Szj
{
internal sealed class Util
{
const string EncryptText = "惺惺惜惺惺";
/// <summary>
/// 加密
/// </summary>
/// <param name="strText"></param>
/// <returns></returns>
public static String Encrypt(String strText)
{
Byte[] byKey = { };
Byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
try
{
byKey = System.Text.Encoding.UTF8.GetBytes(EncryptText.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
Byte[] inputByteArray = Encoding.UTF8.GetBytes(strText);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
return Convert.ToBase64String(ms.ToArray());
}
catch (Exception ex)
{
return ex.Message;
}
}
/// <summary>
/// 解密
/// </summary>
/// <param name="strText"></param>
/// <returns></returns>
public static String Decrypt(String strText)
{
Byte[] byKey = { };
Byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
Byte[] inputByteArray = new byte[strText.Length];
try
{
byKey = System.Text.Encoding.UTF8.GetBytes(EncryptText.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
inputByteArray = Convert.FromBase64String(strText);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
return encoding.GetString(ms.ToArray());
}
catch (Exception ex)
{
return ex.Message;
}
}
public static string MD5(string inStr)
{
MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
byte[] InBytes = Encoding.GetEncoding("GB2312").GetBytes(inStr);
byte[] OutBytes = md5.ComputeHash(InBytes);
string OutString = "";
for (int i = 0; i < OutBytes.Length; i++)
{
OutString += OutBytes[i].ToString("x2");
}
return OutString;
}
}
}
from窗体
if (RegDog.VerifyMachineCode(txtMachineCode.Text.Trim(), txtRegCode.Text.Trim()))
{
MessageBox.Show("注册成功!");
this.DialogResult = DialogResult.OK;
}
else
{
MessageBox.Show("错误的注册码");
}
- 我的c#注册码操作类
- 我的注册码解决方案
- vs2005我的注册码
- 卡巴斯基注册码的操作
- C# 注册码
- 我用到的C#中操作XML的笨方法
- C#中数据库操作相关我给整理的一个类供大家使用完善
- 我的C#之路-日期操作与近期总结
- 我的数据库操作类
- 有人在网上问我的相册软件的注册码。。。。
- 我搜集的各类软件的注册码(免费万岁)
- C#实现注册码代码
- C#生成软件注册码
- C#生成注册码
- C# 生成软件注册码
- 操作oracle的c#类
- C# 操作Excel的类
- C#操作CUR的类
- java 虚拟机参数
- 文本框限制输入(半角,全角互转),以及控制输入法问题,解决方法整合
- AGG网站
- ExtJS Grid Tooltip的实现方式
- MySql command line client(客户端命令行)执行语句!
- 我的c#注册码操作类
- Struts2拦截器简单示例
- C plus plus Concurrency in Action
- 我的那个天哪!
- csdn相册超出了20m了,怎么办?求助
- Struts2原理详解
- 常用SQL系统表
- mysql导入导出
- 使用Npgsql库调用PostgreSQL的函数(存储过程)