⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chkpassword.cs

📁 XP界面优化精灵, XP界面优化精灵
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace XP界面优化精灵
{
	/// <summary>
	/// chkPassword 的摘要说明。
	/// </summary>
	public class chkPassword : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox tb_password;
		private System.Windows.Forms.Button bn_login;
		private System.Windows.Forms.Button bn_exit;
		private System.ComponentModel.IContainer components;
		MainForm mf=new MainForm ();
		private System.Windows.Forms.Label lb_user;
		string oepass="";
		internal static bool isRegistered=false;
		public chkPassword()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(chkPassword));
			this.tb_password = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.bn_login = new System.Windows.Forms.Button();
			this.lb_user = new System.Windows.Forms.Label();
			this.bn_exit = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// tb_password
			// 
			this.tb_password.Location = new System.Drawing.Point(190, 138);
			this.tb_password.Name = "tb_password";
			this.tb_password.PasswordChar = '*';
			this.tb_password.Size = new System.Drawing.Size(152, 21);
			this.tb_password.TabIndex = 0;
			this.tb_password.Text = "";
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.label1.BackColor = System.Drawing.Color.Transparent;
			this.label1.Location = new System.Drawing.Point(192, 114);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(60, 17);
			this.label1.TabIndex = 2;
			this.label1.Text = "登录密码:";
			// 
			// bn_login
			// 
			this.bn_login.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.bn_login.Location = new System.Drawing.Point(364, 136);
			this.bn_login.Name = "bn_login";
			this.bn_login.TabIndex = 3;
			this.bn_login.Text = "登录";
			this.bn_login.Click += new System.EventHandler(this.bn_login_Click);
			// 
			// lb_user
			// 
			this.lb_user.BackColor = System.Drawing.Color.Transparent;
			this.lb_user.Location = new System.Drawing.Point(190, 172);
			this.lb_user.Name = "lb_user";
			this.lb_user.Size = new System.Drawing.Size(160, 14);
			this.lb_user.TabIndex = 4;
			this.lb_user.Text = "使用者:Blake";
			// 
			// bn_exit
			// 
			this.bn_exit.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.bn_exit.Location = new System.Drawing.Point(364, 166);
			this.bn_exit.Name = "bn_exit";
			this.bn_exit.TabIndex = 6;
			this.bn_exit.Text = "退出";
			this.bn_exit.Click += new System.EventHandler(this.bn_exit_Click);
			// 
			// chkPassword
			// 
			this.AcceptButton = this.bn_login;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.ClientSize = new System.Drawing.Size(562, 294);
			this.ControlBox = false;
			this.Controls.Add(this.bn_exit);
			this.Controls.Add(this.lb_user);
			this.Controls.Add(this.bn_login);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.tb_password);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
			this.HelpButton = true;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "chkPassword";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "密码验证-XP界面优化精灵";
			this.TopMost = true;
			this.Load += new System.EventHandler(this.chkPassword_Load);
			this.ResumeLayout(false);

		}
		#endregion
		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new chkPassword());
		}
		private void chkPassword_Load(object sender, System.EventArgs e)
		{
			#region 注册信息判断
			try
			{
				string UserName="";
				string UserID="";
				string RegisterKey=action.GetRegisterInfo (ref UserName,ref UserID);
				if(RegisterKey==null || RegisterKey.Length ==0)
				{
					RegisterKey=action.RegisteredProduct ("",false);
				}
				if(RegisterKey!="" )
				{
					if(chkPassword.RegisterProduct(UserName,UserID,RegisterKey))
					{
						isRegistered=true;
					}
				}
				if(!isRegistered)
				{
					MessageBox.Show ("你还未注册本软件,请您注册。",action.Caption);
				}
			}
			catch
			{
			}
			#endregion
			
			#region 启动状态
			//程序参数判断
			try
			{
				string [] param =System.Environment.GetCommandLineArgs ();
				if(param.Length>1)
				{
					if(param[2]=="XPSuite")
					{
						xpsuite.commandLoadpath =param[1];
						xpsuite xp=new xpsuite ();
						xp.ShowDialog ();
					}
				}
				else
				{
					this.lb_user.Text="当前使用者:"+System.Environment.UserName;
					oepass=action.getPassword ();
					if( oepass!=null)
					{
						if(oepass.Length <=0)
						{
							this.Opacity =0.0;
							mf.Show ();
						}
					}
					else
					{
						this.Opacity =0.0;
						mf.Show ();
					}
				}
			}
			catch
			{
			}
			#endregion
		}

		private void bn_login_Click(object sender, System.EventArgs e)
		{
			if(action.Encryption (this.tb_password .Text) ==oepass)
			{
				mf.Show ();
				this.Hide ();
			}
			else
			{
				MessageBox.Show ("密码不正确!",action.Caption);
			}
		}

		private void bn_exit_Click(object sender, System.EventArgs e)
		{
			Application.Exit ();
		}
		internal static  string EncryptID(string UserName)
		{
			byte [] b=System.Text.Encoding.ASCII.GetBytes(UserName.PadRight(4,'S').ToUpper());
			byte[] b2=System.Text.Encoding.Unicode.GetBytes ("SGSOFT".PadRight(b.Length,'S'));
			string temp="";
			int i=0;
			foreach(byte bb in b)
			{
				char c=(char)(bb+b2[i]);
				temp+=System.Uri.HexEscape(c).Remove (0,1);
				i++;
			}
			byte [] part1=System.Text.Encoding.ASCII.GetBytes(temp.PadRight(4,'S').Substring(0,4));
			byte [] part2=System.Text.Encoding.ASCII.GetBytes(temp.PadRight(8,'G').Substring (temp.Length-4,4));
			byte [] ctime=System.Text.Encoding.ASCII.GetBytes(System.DateTime.Now.ToShortDateString().PadRight(8,'S').Substring (0,8).ToUpper ());
			byte [] cuser=System.Text.Encoding.ASCII.GetBytes(System.Environment.UserName.PadRight(8,'O').Substring (0,8).ToUpper ());
			byte [] Mname=System.Text.Encoding.ASCII.GetBytes(System.Environment.MachineName.PadRight(8,'F').Substring (0,8).ToUpper ());
			byte [] UDname=System.Text.Encoding.ASCII.GetBytes(System.Environment.UserDomainName.PadRight(8,'T').Substring (0,8).ToUpper ());
			string sepa1="";
			string sepa2="";
			for(int n=0;n<4;n++)
			{
				byte epa1=(byte)((ctime[n]+cuser[n])*2-n-(part1[n]+part2[3-n]*2-ctime[7-n]));
				char ec1=(char)epa1;
				sepa1+=System.Uri.HexEscape(ec1).Remove (0,1);
				byte epa2=(byte)((Mname[n]+UDname[n])*2-n-(part2[n]+part1[3-n]));
				char ec2=(char)epa2;
				sepa2+=System.Uri.HexEscape(ec2).Remove (0,1);
			}
			return "SGSOFT-"+sepa1+sepa2;
		}
		internal static bool RegisterProduct(string UserName,string UserID,string RegisterKey)
		{
			string code1=RegisterKey.Substring (0,5);
			string code2=RegisterKey.Substring (6,5);			
			string code3=RegisterKey.Substring (12,5);
			string code4=RegisterKey.Substring (18,5);
			if(code1.Substring (0,3)== "SGS")
			{
				string chkcode2="";
				string temp2=UserID.Substring (7,6);
				byte l2=0;
				for(int i=0 ;i<5;i++)
				{
					l2=(byte)((temp2.IndexOf(temp2.Substring (i,1)+1))*10+(temp2.Length-temp2.LastIndexOf(temp2.Substring (i,1)))+160);
					int d2=int.Parse (temp2.Substring (i,1),System.Globalization.NumberStyles.AllowHexSpecifier);
					char c=(char)(l2+d2);
					chkcode2+=System.Uri.HexEscape (c).Remove (0,1);
				}
				chkcode2=chkcode2.Substring (0,5);
				if(code2==chkcode2)
				{
					string chkcode3="";
					string temp3=UserID.Substring (12,6);
					byte l3=0;
					for(int i=0 ;i<5;i++)
					{
						l3=(byte)((temp3.IndexOf(temp3.Substring (i,1)+1))*10+(temp3.Length-temp3.LastIndexOf(temp3.Substring (i,1)))%14*17);
						int d3=int.Parse (temp3.Substring (i,1),System.Globalization.NumberStyles.AllowHexSpecifier);
						char c=(char)(l3+d3);
						chkcode3+=System.Uri.HexEscape (c).Remove (0,2);
					}
					if(code3== chkcode3)
					{
						string chkcode4="";
						string temp4=UserID.Substring (17,6);
						byte l4=0;
						for(int i=0 ;i<5;i++)
						{
							l4=(byte)((temp4.IndexOf(temp4.Substring (i,1)+1))*10+(temp4.Length-temp4.LastIndexOf(temp4.Substring (i,1)))%16*14);
							int d4=int.Parse (temp4.Substring (i,1),System.Globalization.NumberStyles.AllowHexSpecifier);
							char c=(char)(l4+d4);
							chkcode4+=System.Uri.HexEscape (c).Remove (0,2);
						}
						if(code4== chkcode4)
						{
							return true;
						}
					}
				}
			}
			return false;
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -