using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using digimoto;
namespace digimoto
{
	/// <summary>
	/// Zusammenfassung für Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.PictureBox pictureBox1;
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox textBox2;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.Panel panel2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.Label label4;
		/// <summary>
		/// Erforderliche Designervariable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			//
			// Erforderlich für die Windows Form-Designerunterstützung
			//
			InitializeComponent();

			//
			// TODO: Fügen Sie den Konstruktorcode nach dem Aufruf von InitializeComponent hinzu
			//
		}

		/// <summary>
		/// Die verwendeten Ressourcen bereinigen.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Vom Windows Form-Designer generierter Code
		/// <summary>
		/// Erforderliche Methode für die Designerunterstützung. 
		/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.panel1 = new System.Windows.Forms.Panel();
			this.label2 = new System.Windows.Forms.Label();
			this.button1 = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.textBox2 = new System.Windows.Forms.TextBox();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.panel2 = new System.Windows.Forms.Panel();
			this.label3 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.panel1.SuspendLayout();
			this.panel2.SuspendLayout();
			this.SuspendLayout();
			// 
			// pictureBox1
			// 
			this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Location = new System.Drawing.Point(5, 5);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(94, 302);
			this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
			this.pictureBox1.TabIndex = 3;
			this.pictureBox1.TabStop = false;
			// 
			// panel1
			// 
			this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.panel1.Controls.Add(this.label2);
			this.panel1.Controls.Add(this.button1);
			this.panel1.Controls.Add(this.label1);
			this.panel1.Controls.Add(this.textBox2);
			this.panel1.Controls.Add(this.textBox1);
			this.panel1.Location = new System.Drawing.Point(104, 5);
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(224, 144);
			this.panel1.TabIndex = 7;
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(8, 64);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(100, 16);
			this.label2.TabIndex = 11;
			this.label2.Text = "LicenceKey";
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(16, 104);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(192, 23);
			this.button1.TabIndex = 10;
			this.button1.Text = "Generate and copy to clip";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 8);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(100, 16);
			this.label1.TabIndex = 9;
			this.label1.Text = "CustomerID";
			// 
			// textBox2
			// 
			this.textBox2.Location = new System.Drawing.Point(16, 80);
			this.textBox2.Name = "textBox2";
			this.textBox2.ReadOnly = true;
			this.textBox2.Size = new System.Drawing.Size(192, 20);
			this.textBox2.TabIndex = 8;
			this.textBox2.Text = "";
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(16, 32);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(192, 20);
			this.textBox1.TabIndex = 7;
			this.textBox1.Text = "Keygen by Ducky";
			// 
			// panel2
			// 
			this.panel2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.panel2.Controls.Add(this.label4);
			this.panel2.Controls.Add(this.label3);
			this.panel2.Location = new System.Drawing.Point(104, 155);
			this.panel2.Name = "panel2";
			this.panel2.Size = new System.Drawing.Size(224, 152);
			this.panel2.TabIndex = 8;
			// 
			// label3
			// 
			this.label3.Font = new System.Drawing.Font("Times New Roman", 14.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label3.Location = new System.Drawing.Point(24, 8);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(176, 24);
			this.label3.TabIndex = 0;
			this.label3.Text = "Digimoto 3.7 Keygen";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(0, 40);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(224, 88);
			this.label4.TabIndex = 1;
			this.label4.Text = "Digimoto is the ultimate solution for vehicle diagnostics, dynamometer readings a" +
				"nd statistical analysis. It uses the ELM32X Interface to read the vehicle inform" +
				"ations over OBD II";
			this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(333, 312);
			this.Controls.Add(this.panel2);
			this.Controls.Add(this.panel1);
			this.Controls.Add(this.pictureBox1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.Name = "Form1";
			this.Text = "Digimoto 3.7 Keygen by Ducky";
			this.panel1.ResumeLayout(false);
			this.panel2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// Der Haupteinstiegspunkt für die Anwendung.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}
		public static string GetLicense(string PublicKey, string PrivateKey)
		{
			string str2 = string.Empty;

			PublicKey = PublicKey.ToLower();
			byte[] bs2 = new System.Text.ASCIIEncoding().GetBytes(PrivateKey);
			byte[] bs1 = Crypto.Encrypt(PublicKey, bs2);
			int i = 0;
			do
			{
				string str3 = Convert.ToString(Convert.ToInt32(bs1[i]));
				if (str3.Length == 0)
				{
					str3 = "000";
				}
				if (str3.Length == 1)
				{
					str3 = String.Concat("00", str3);
				}
				if (str3.Length == 2)
				{
					str3 = String.Concat("0", str3);
				}
				str2 = String.Concat(str2, str3);
				i++;
			}
			while (i <= 7);
			return KeyBuilder(str2);
		}

		public static string KeyBuilder(string License)
		{
			int[] nums = new int[25];
			int j = 1;
			do
			{
				nums[j - 1] = Convert.ToInt32(License.Substring(j-1, 1));
				j++;
			}
			while (j <= 24);
			string str4 = "";
			j = 1;
			do
			{
				str4 = String.Concat(str4, Convert.ToString(nums[j * 3 - 1]));
				j++;
			}
			while (j <= 8);
			string str2 = "";
			j = 1;
			do
			{
				int i = nums[j * 3 - 3] + nums[j * 3 - 2];
				switch (i)
				{
					case 26:
						str2 = String.Concat(str2, "b");
						break;

					case 27:
						str2 = String.Concat(str2, "e");
						break;

					case 28:
						str2 = String.Concat(str2, "l");
						break;

					case 29:
						str2 = String.Concat(str2, "a");
						break;

					default:
						str2 = String.Concat(str2, (char)(i + 65));
						break;
				}
				j++;
			}
			while (j <= 8);
			return String.Concat(str4, str2);
		}


		private void button1_Click(object sender, System.EventArgs e)
		{
			textBox2.Text = GetLicense(textBox1.Text,"digi36");
			Clipboard.SetDataObject(textBox2.Text,true);
		}
	}
}
