Google Reverse Image Upload and Search Using Java Desktop


Google Reverse Image Upload and Search Using Java Desktop

Cross-platform compatibility like Windows, Linux, Unix and Mac too

google image reverse search
Google Image reverse search

Google.java

import java.awt.Component;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;

import javax.swing.JOptionPane;

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.DefaultHttpClient;

@SuppressWarnings("deprecation")
public class Google {

	/**
	 * @param args
	 */
		private static String OS = System.getProperty("os.name").toLowerCase();

		public static void main(String[] args) {

			Component frame = null;

			String exePath="ned.jpg";
			String imageFile = exePath;
			File exeFile=new File(imageFile);

			// TODO Auto-generated method stub
			try {
				@SuppressWarnings("resource")
				HttpClient client = new DefaultHttpClient();
				String url = "https://www.google.com/searchbyimage/upload";

				if (isWindows()) {

					exeFile.getAbsoluteFile();
				}
				else if (isMac()) {
					exeFile.getAbsoluteFile();
				} else if (isUnix()) {
					exeFile.getAbsoluteFile();
				}
				HttpPost post = new HttpPost(url);
				Runtime rt = Runtime.getRuntime();

				MultipartEntity entity = new MultipartEntity();
				entity.addPart("encoded_image", new FileBody(new File(imageFile)));
				entity.addPart("image_url", new StringBody(""));
				entity.addPart("image_content", new StringBody(""));
				entity.addPart("filename", new StringBody(""));
				entity.addPart("h1", new StringBody("en"));
				entity.addPart("bih", new StringBody("179"));
				entity.addPart("biw", new StringBody("1600"));

				post.setEntity(entity);
				HttpResponse response = client.execute(post);
				BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

				String line = "";
				String someStr = "";
				while ((line = rd.readLine()) != null) {
					if (line.indexOf("HREF") > 0)
						try {
							someStr = line.substring(9,line.lastIndexOf("\">here</A>."))
									+ "";
							if (isWindows()) {

								// this doesn't support showing URL in the form of page.html#nameLink"
								System.out.println(OS);
								rt.exec("rundll32 url.dll,FileProtocolHandler "+ someStr);

							} else if (isMac()) {
								System.out.println(OS);
								rt.exec("open " + someStr);

							} else if (isUnix()) {
								// Do a best guess on Unix until we get a platform independent way
								// Build a list of browsers to try, in this order.
								String[] browsers = { "epiphany", "firefox","mozilla", "konqueror", "netscape","opera", "links", "lynx" };

								// Build a command string which looks like browser1 "URL" || browser2 "URL" ||..."
								StringBuffer cmd = new StringBuffer();
								for (int i = 0; i < browsers.length; i++)
									cmd.append((i == 0 ? "" : " || ") + browsers[i]+ " \"" + someStr + "\" ");

								rt.exec(new String[] { "sh", "-c", cmd.toString() });
								System.out.println(OS);
							} else {
								return;
							}
						} catch (Exception e) {
							System.out.println("Ponka");
							JOptionPane.showMessageDialog(frame,"Wrong Operating System " + e + OS,"Inane error", JOptionPane.ERROR_MESSAGE);
						}

				}

			} catch (ClientProtocolException cpx) {

				JOptionPane.showMessageDialog(frame, "Error " + cpx, "Inane error",JOptionPane.ERROR_MESSAGE);
				cpx.printStackTrace();

			} catch (IOException ioex) {
				JOptionPane.showMessageDialog(frame, "File not Found at " + ioex,"Inane error", JOptionPane.ERROR_MESSAGE);
				ioex.printStackTrace();
			}
		}

		public static boolean isWindows() {

			return (OS.indexOf("win") >= 0);

		}

		public static boolean isMac() {

			return (OS.indexOf("mac") >= 0);

		}

		public static boolean isUnix() {

			return (OS.indexOf("nix") >= 0 || OS.indexOf("nux") >= 0 || OS.indexOf("aix") > 0);

		}

		public static boolean isSolaris() {

			return (OS.indexOf("sunos") >= 0);

		}

}

click-here

click-here-jar

PHP & MySQL Database Insert View & Search


insert

Create Database

CREATE DATABASE alumni;
USE alumni;
CREATE TABLE `students` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Title` varchar(255) DEFAULT NULL,
  `Name` varchar(255) DEFAULT NULL,
  `Batch` varchar(255) DEFAULT NULL,
  `Contact` varchar(255) DEFAULT NULL,
  `Email` varchar(255) DEFAULT NULL,
  `FProject` varchar(255) DEFAULT NULL,
  `Designation` varchar(255) DEFAULT NULL,
  `CName` varchar(255) DEFAULT NULL,
  `Location` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

insert.php

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Electronic Engineering Alumni</pre>
<style type="text/css"><!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #CF9;
}
--></style>
<pre>

</pre>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="center">
<table width="50%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="font-family: Arial, Helvetica, sans-serif; size: 35px; color: #c60; font-weight: bold;" align="center"></td>
</tr>
<tr>
<td style="font-family: Arial, Helvetica, sans-serif; size: 35px; color: #c60; font-weight: bold;" align="center"><strong>Electronic Engineering Alumni</strong></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td align="center">
<table width="50%" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td align="center"><a href="insert.php">INSERT</a></td>
<td align="center"><a href="search.php">SERACH</a></td>
<td align="center"><a href="list.php">LIST</a></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td align="center"></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td align="center"><form action="query.php" method="post">
<table width="400" border="0" cellspacing="5" cellpadding="5">
<tbody>
<tr>
<td width="130">Title:</td>
<td width="335">
<label for="Title"></label>
<select id="Title" name="Title"><option value="Mr.">Mr.</option><option value="Ms.">Ms.</option></select></td>
</tr>
<tr>
<td>Name:</td>
<td><input id="Name" type="text" name="Name" /></td>
</tr>
<tr>
<td>Batch:</td>
<td><input id="Batch" type="text" name="Batch" /></td>
</tr>
<tr>
<td>Contact:</td>
<td><input id="Contact" type="text" name="Contact" /></td>
</tr>
<tr>
<td>Email:</td>
<td><input id="Email" type="text" name="Email" /></td>
</tr>
<tr>
<td>FYP:</td>
<td><input id="FYP" type="text" name="FYP" /></td>
</tr>
<tr>
<td>Designation:</td>
<td><input id="Designation" type="text" name="Designation" /></td>
</tr>
<tr>
<td>Company Name:</td>
<td><input id="CName" type="text" name="CName" /></td>
</tr>
<tr>
<td>Location:</td>
<td><input id="Location" type="text" name="Location" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" /></td>
</tr>
</tbody>
</table>
</form></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<pre>

query.php

<?php
$con=mysqli_connect("localhost","root","","alumni");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$sql="INSERT INTO students (Title, Name, Batch, Contact, Email, FProject, Designation, CName, Location)
VALUES
('$_POST[Title]','$_POST[Name]','$_POST[Batch]','$_POST[Contact]','$_POST[Email]','$_POST[FYP]','$_POST[Designation]','$_POST[CName]','$_POST[Location]')";

if (!mysqli_query($con,$sql))
  {
  die('Error: ' . mysqli_error());
  }
$url = 'insert.Php';
echo "1 record added";
echo '<META HTTP-EQUIV=Refresh CONTENT="5; URL='.$url.'">';
mysqli_close($con);
?>

Search
search

search.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Electronic Engineering Alumni</title>
<style type="text/css">
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #CF9;
}
</style>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center"><table width="50%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="center" style="font-family:Arial, Helvetica, sans-serif; size:35px; color:#C60; font-weight:bold;">&nbsp;</td>
      </tr>
      <tr>
        <td align="center" style="font-family:Arial, Helvetica, sans-serif; size:35px; color:#C60; font-weight:bold;"><strong>Electronic Engineering Alumni</strong></td>
        </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td align="center"><table width="50%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td align="center"><a href="insert.php">INSERT</a></td>
            <td align="center"><a href="search.php">SERACH</a></td>
            <td align="center"><a href="list.php">LIST</a></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td align="center">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        </tr>
      <tr>
        <td align="center"><form id="form1" name="form1" method="post" action="search-result.php">
          <table width="50%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="36%" align="center">Search:</td>
              <td width="32%" align="left"><label for="search"></label>
                <input type="text" name="search" id="search" /></td>
              <td width="32%" align="left"><label for="select"></label>
                <select name="select" id="select">
<option value="Name">Name</option>
<option value="ID">ID</option>
                  <option value="Batch">Batch</option>
                  <option value="Email">Email</option>
                  <option value="Location">Location</option>
                </select></td>
            </tr>
            <tr>
              <td align="center">&nbsp;</td>
              <td align="center">&nbsp;</td>
              <td align="center">&nbsp;</td>
            </tr>
            <tr>
              <td align="center">&nbsp;</td>
              <td align="center"><input type="submit" name="submit" id="submit" value="Submit" /></td>
              <td align="center">&nbsp;</td>
            </tr>
          </table>
        </form></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>

search-results.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Electronic Engineering Alumni</title>
<style type="text/css">
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #CF9;
}
</style>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center"><table width="50%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="center" style="font-family:Arial, Helvetica, sans-serif; size:35px; color:#C60; font-weight:bold;">&nbsp;</td>
      </tr>
      <tr>
        <td align="center" style="font-family:Arial, Helvetica, sans-serif; size:35px; color:#C60; font-weight:bold;"><strong>Electronic Engineering Alumni</strong></td>
        </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td align="center"><table width="50%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td align="center"><a href="insert.php">INSERT</a></td>
            <td align="center"><a href="search.php">SERACH</a></td>
            <td align="center"><a href="list.php">LIST</a></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td align="center">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        </tr>
      <tr>
        <td align="center"><?php
$search = mysql_real_escape_string($_POST['search']);
$select = mysql_real_escape_string($_POST['select']);
$con=mysqli_connect("localhost","root","","alumni");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

$data = mysqli_query($con, "SELECT * FROM students WHERE $select LIKE '$search'"); 
while($result = mysqli_fetch_array( $data )) 
 { 
 echo $result['ID']; 
 echo " "; 
 echo $result['Name']; 
 echo " "; 
 echo $result['Batch']; 
 echo "<br>"; 
 } 
 
$anymatches=mysqli_num_rows($data);
if ($anymatches == 0) 
 { 
 echo "Sorry, but we can not find an entry to match your query<br><br>"; 
 } 
 
 //And we remind them what they searched for 
 echo "<b>Searched Result For:</b> " .$search; 

mysqli_close($con);
?> </td>
      </tr>
    </table></td>
  </tr>
</table>


</body>
</html>

View
view
list.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Electronic Engineering Alumni</title>
<style type="text/css">
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #CF9;
}
</style>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center"><table width="50%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="center" style="font-family:Arial, Helvetica, sans-serif; size:35px; color:#C60; font-weight:bold;">&nbsp;</td>
      </tr>
      <tr>
        <td align="center" style="font-family:Arial, Helvetica, sans-serif; size:35px; color:#C60; font-weight:bold;"><strong>Electronic Engineering Alumni</strong></td>
        </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td align="center"><table width="50%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td align="center"><a href="insert.php">INSERT</a></td>
            <td align="center"><a href="search.php">SERACH</a></td>
            <td align="center"><a href="list.php">LIST</a></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td align="center">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        </tr>
      <tr>
        <td align="center">
        <?php
$con=mysqli_connect("localhost","root","","alumni");
// Check connection


if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }


$result = mysqli_query($con,"SELECT * FROM students");
echo "<table border='1' cellspacing='2' cellpadding='2'>
<tr>
<th>ID</th>
<th>Name</th>
<th>Batch</th>
<th>Contact</th>
<th>Email</th>
<th>FYP</th>
<th>Designation</th>
<th>Company Name</th>
<th>Location</th>
</tr>";

while($row = mysqli_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['ID'] . "</td>";
  echo "<td>" . $row['Name'] . "</td>";
  echo "<td>" . $row['Batch'] . "</td>";
  echo "<td>" . $row['Contact'] . "</td>";
  echo "<td>" . $row['Email'] . "</td>";
  echo "<td>" . $row['FProject'] . "</td>";
  echo "<td>" . $row['Designation'] . "</td>";
  echo "<td>" . $row['CName'] . "</td>";
  echo "<td>" . $row['Location'] . "</td>";
  echo "</tr>";
  }
mysqli_close($con);
?> 
        </td>
      </tr>
    </table></td>
  </tr>
</table>


</body>
</html>

Registration Form Using C#


Email Function using Dot Net Gmail account
Registration Form Email Function using C# & Gmail account

Form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.Mail;

namespace EMAIL_GMAIL
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string txtemail = &amp;quot;abc@gmail.com&amp;quot;; //Your Gmail Email Account Address
            string txtpass = &amp;quot;123abc&amp;quot;; // Your Gmail Email Account Password
            string txtsubject = &amp;quot;Account Information Detail&amp;quot;;
            string txtmessage = &amp;quot;&amp;lt;b&amp;gt;Hello &amp;quot; + txtFName.Text + &amp;quot; &amp;quot; + txtLName.Text + &amp;quot;,&amp;lt;/b&amp;gt; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt; Thankyou for joining us. &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;b&amp;gt; Your Account Detail is &amp;lt;/b&amp;gt;&amp;lt;br&amp;gt; &amp;lt;b&amp;gt;Usename:&amp;lt;/b&amp;gt; &amp;quot; + txtusername.Text + &amp;quot;&amp;lt;br&amp;gt; &amp;lt;b&amp;gt;Password: &amp;lt;/b&amp;gt; &amp;quot; + txtpassword.Text + &amp;quot; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt; &amp;lt;b&amp;gt;Kind Regards,&amp;lt;/b&amp;gt; &amp;lt;br&amp;gt; Leave Management System Team&amp;quot;;

            MailMessage mail = new MailMessage();
            this.Cursor = Cursors.WaitCursor;

            using (MailMessage mailMessage = new MailMessage(new MailAddress(txtEmail.Text), new MailAddress(txtEmail.Text)))
            {
                mailMessage.Body = txtmessage;
                mailMessage.Subject = txtsubject;

                try
                {
                    SmtpClient SmtpServer = new SmtpClient();
                    SmtpServer.Credentials = new System.Net.NetworkCredential(txtemail, txtpass);
                    SmtpServer.Port = 587;
                    SmtpServer.Host = &amp;quot;smtp.gmail.com&amp;quot;;
                    SmtpServer.EnableSsl = true;
                    mail = new MailMessage();
                    String[] addr = txtEmail.Text.Split(',');
                    mail.From = new MailAddress(txtemail, &amp;quot;Leave Management System&amp;quot;);
                    Byte i;
                    for (i = 0; i &amp;lt; addr.Length; i++)
                        mail.To.Add(addr[i]);
                    mail.Subject = txtsubject;
                    mail.Body = txtmessage;
                    mail.ReplyTo = new MailAddress(txtemail);
                    mail.IsBodyHtml = true;
                    mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
                    SmtpServer.Send(mail);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, &amp;quot;EMail&amp;quot;, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }

                finally
                {
                    this.Cursor = Cursors.Arrow;
                    button1.Enabled = true;
                    MessageBox.Show(&amp;quot;Your Information Send&amp;quot;);
                }
            }

       }


    }
}

Form1.Designer.cs

namespace EMAIL_GMAIL
{
    partial class Form1
    {
        /// &amp;lt;summary&amp;gt;
        /// Required designer variable.
        /// &amp;lt;/summary&amp;gt;
        private System.ComponentModel.IContainer components = null;

        /// &amp;lt;summary&amp;gt;
        /// Clean up any resources being used.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name=&amp;quot;disposing&amp;quot;&amp;gt;true if managed resources should be disposed; otherwise, false.&amp;lt;/param&amp;gt;
        protected override void Dispose(bool disposing)
        {
            if (disposing &amp;amp;&amp;amp; (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// &amp;lt;summary&amp;gt;
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// &amp;lt;/summary&amp;gt;
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.button1 = new System.Windows.Forms.Button();
            this.txtFName = new System.Windows.Forms.TextBox();
            this.txtusername = new System.Windows.Forms.TextBox();
            this.txtLName = new System.Windows.Forms.TextBox();
            this.txtpassword = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.label5 = new System.Windows.Forms.Label();
            this.label6 = new System.Windows.Forms.Label();
            this.txtEmail = new System.Windows.Forms.TextBox();
            this.SuspendLayout();
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(334, 403);
            this.button1.Name = &amp;quot;button1&amp;quot;;
            this.button1.Size = new System.Drawing.Size(75, 23);
            this.button1.TabIndex = 8;
            this.button1.Text = &amp;quot;Send&amp;quot;;
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new System.EventHandler(this.button1_Click);
            // 
            // txtFName
            // 
            this.txtFName.Font = new System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtFName.Location = new System.Drawing.Point(147, 126);
            this.txtFName.Name = &amp;quot;txtFName&amp;quot;;
            this.txtFName.Size = new System.Drawing.Size(199, 26);
            this.txtFName.TabIndex = 1;
            // 
            // txtusername
            // 
            this.txtusername.Font = new System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtusername.Location = new System.Drawing.Point(147, 245);
            this.txtusername.Name = &amp;quot;txtusername&amp;quot;;
            this.txtusername.Size = new System.Drawing.Size(199, 26);
            this.txtusername.TabIndex = 3;
            // 
            // txtLName
            // 
            this.txtLName.Font = new System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtLName.Location = new System.Drawing.Point(497, 126);
            this.txtLName.Name = &amp;quot;txtLName&amp;quot;;
            this.txtLName.Size = new System.Drawing.Size(199, 26);
            this.txtLName.TabIndex = 2;
            // 
            // txtpassword
            // 
            this.txtpassword.Font = new System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtpassword.Location = new System.Drawing.Point(497, 245);
            this.txtpassword.Name = &amp;quot;txtpassword&amp;quot;;
            this.txtpassword.PasswordChar = '*';
            this.txtpassword.Size = new System.Drawing.Size(199, 26);
            this.txtpassword.TabIndex = 4;
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Font = new System.Drawing.Font(&amp;quot;Arial&amp;quot;, 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label1.ForeColor = System.Drawing.Color.Indigo;
            this.label1.Location = new System.Drawing.Point(28, 129);
            this.label1.Name = &amp;quot;label1&amp;quot;;
            this.label1.Size = new System.Drawing.Size(91, 19);
            this.label1.TabIndex = 8;
            this.label1.Text = &amp;quot;First Name&amp;quot;;
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Font = new System.Drawing.Font(&amp;quot;Arial&amp;quot;, 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.ForeColor = System.Drawing.Color.Indigo;
            this.label2.Location = new System.Drawing.Point(396, 129);
            this.label2.Name = &amp;quot;label2&amp;quot;;
            this.label2.Size = new System.Drawing.Size(90, 19);
            this.label2.TabIndex = 9;
            this.label2.Text = &amp;quot;Last Name&amp;quot;;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Font = new System.Drawing.Font(&amp;quot;Arial&amp;quot;, 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label3.ForeColor = System.Drawing.Color.Indigo;
            this.label3.Location = new System.Drawing.Point(28, 251);
            this.label3.Name = &amp;quot;label3&amp;quot;;
            this.label3.Size = new System.Drawing.Size(87, 19);
            this.label3.TabIndex = 10;
            this.label3.Text = &amp;quot;Username&amp;quot;;
            // 
            // label4
            // 
            this.label4.AutoSize = true;
            this.label4.Font = new System.Drawing.Font(&amp;quot;Arial&amp;quot;, 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label4.ForeColor = System.Drawing.Color.Indigo;
            this.label4.Location = new System.Drawing.Point(396, 251);
            this.label4.Name = &amp;quot;label4&amp;quot;;
            this.label4.Size = new System.Drawing.Size(86, 19);
            this.label4.TabIndex = 11;
            this.label4.Text = &amp;quot;Password&amp;quot;;
            // 
            // label5
            // 
            this.label5.AutoSize = true;
            this.label5.Font = new System.Drawing.Font(&amp;quot;Arial&amp;quot;, 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label5.ForeColor = System.Drawing.Color.Indigo;
            this.label5.Location = new System.Drawing.Point(226, 41);
            this.label5.Name = &amp;quot;label5&amp;quot;;
            this.label5.Size = new System.Drawing.Size(271, 24);
            this.label5.TabIndex = 12;
            this.label5.Text = &amp;quot;Registration Form Dot Net&amp;quot;;
            // 
            // label6
            // 
            this.label6.AutoSize = true;
            this.label6.Font = new System.Drawing.Font(&amp;quot;Arial&amp;quot;, 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label6.ForeColor = System.Drawing.Color.Indigo;
            this.label6.Location = new System.Drawing.Point(206, 345);
            this.label6.Name = &amp;quot;label6&amp;quot;;
            this.label6.Size = new System.Drawing.Size(51, 19);
            this.label6.TabIndex = 14;
            this.label6.Text = &amp;quot;Email&amp;quot;;
            // 
            // txtEmail
            // 
            this.txtEmail.Font = new System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtEmail.Location = new System.Drawing.Point(298, 340);
            this.txtEmail.Name = &amp;quot;txtEmail&amp;quot;;
            this.txtEmail.Size = new System.Drawing.Size(199, 26);
            this.txtEmail.TabIndex = 5;
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.Color.White;
            this.ClientSize = new System.Drawing.Size(751, 462);
            this.Controls.Add(this.label6);
            this.Controls.Add(this.txtEmail);
            this.Controls.Add(this.label5);
            this.Controls.Add(this.label4);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.txtpassword);
            this.Controls.Add(this.txtLName);
            this.Controls.Add(this.txtusername);
            this.Controls.Add(this.txtFName);
            this.Controls.Add(this.button1);
            this.ForeColor = System.Drawing.Color.Indigo;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject(&amp;quot;$this.Icon&amp;quot;)));
            this.Name = &amp;quot;Form1&amp;quot;;
            this.Text = &amp;quot;Email Function&amp;quot;;
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.TextBox txtFName;
        private System.Windows.Forms.TextBox txtusername;
        private System.Windows.Forms.TextBox txtLName;
        private System.Windows.Forms.TextBox txtpassword;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.Label label6;
        private System.Windows.Forms.TextBox txtEmail;
    }
}

Password Encrypt & Decrypt


Secure Password Programming with .NET

Password Encrypting and Decrypting
Password Encrypting and Decrypt

Form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Security.Cryptography;

namespace hashwin
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        public string SetKey()
        {
            return "hammad";
        }

        private void btnEncrypt_Click(object sender, EventArgs e)
        {
            textBox2.Text = Class1.Encrypt(textBox1.Text, SetKey());
        }

        private void btnDecrypt_Click(object sender, EventArgs e)
        {
            textBox4.Text = Class1.Decrypt(textBox3.Text, SetKey());
        }
    }
}

Class1.cs

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Security.Cryptography;
using System.Text;

public class Class1
{
    private static string _key;

    public Class1()
	{
	}

    public static string Key
    {
        set
        {
            _key = value;
        }
    }

    public static string Encrypt(string strToEncrypt)
    {
        try
        {
            return Encrypt(strToEncrypt, _key);
        }
        catch (Exception ex)
        {
            return "Wrong Input. " + ex.Message;
        }

    }

    public static string Decrypt(string strEncrypted)
    {
        try
        {
            return Decrypt(strEncrypted, _key);
        }
        catch (Exception ex)
        {
            return "Wrong Input. " + ex.Message;
        }
    }

    public static string Encrypt(string strToEncrypt, string strKey)
    {
        try
        {
            TripleDESCryptoServiceProvider objDESCrypto = new TripleDESCryptoServiceProvider();
            MD5CryptoServiceProvider objHashMD5 = new MD5CryptoServiceProvider();

            byte[] byteHash, byteBuff;
            string strTempKey = strKey;

            byteHash = objHashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(strTempKey));
            objHashMD5 = null;
            objDESCrypto.Key = byteHash;
            objDESCrypto.Mode = CipherMode.ECB;

            byteBuff = ASCIIEncoding.ASCII.GetBytes(strToEncrypt);
            return Convert.ToBase64String(objDESCrypto.CreateEncryptor().TransformFinalBlock(byteBuff, 0, byteBuff.Length));
        }
        catch (Exception ex)
        {
            return "Wrong Input. " + ex.Message;
        }
    }

    public static string Decrypt(string strEncrypted, string strKey)
    {
        try
        {
            TripleDESCryptoServiceProvider objDESCrypto = new TripleDESCryptoServiceProvider();
            MD5CryptoServiceProvider objHashMD5 = new MD5CryptoServiceProvider();

            byte[] byteHash, byteBuff;
            string strTempKey = strKey;

            byteHash = objHashMD5.ComputeHash(ASCIIEncoding.ASCII.GetBytes(strTempKey));
            objHashMD5 = null;
            objDESCrypto.Key = byteHash;
            objDESCrypto.Mode = CipherMode.ECB;

            byteBuff = Convert.FromBase64String(strEncrypted);
            string strDecrypted = ASCIIEncoding.ASCII.GetString(objDESCrypto.CreateDecryptor().TransformFinalBlock(byteBuff, 0, byteBuff.Length));
            objDESCrypto = null;

            return strDecrypted;
        }
        catch (Exception ex)
        {
            return "Wrong Input. " + ex.Message;
        }
    }
}

If you want this project email me. h4hammad[at]live[.]com

Google Earth Long Lat


This C# application demonstrates how to create a simple Google Earth Longitude and Latitude value point application, that create Google Earth KML file on user desktop and then open it in Google Application. This project is my First Semester Software Engineering Project and its open sourceĀ  :). Application Requirements:

  • Google Earth
  • Visual Studio 2010 or 2012
  • Little Knowledge about C# :)

Software Overview:

Google Earth Longitude and Latitude

Source Code:

Form1.Designer.cs]

namespace Google
{
partial class Form1
{
/// 
/// Required designer variable.
/// 
private System.ComponentModel.IContainer components = null;

/// 
/// Clean up any resources being used.
/// 
///true if managed resources should be disposed; otherwise, false.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// 
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// 
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.TextBox2 = new System.Windows.Forms.TextBox();
this.TextBox1 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label2
//
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.SystemColors.ControlText;
this.label2.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.ForeColor = System.Drawing.Color.AliceBlue;
this.label2.Location = new System.Drawing.Point(193, 250);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(87, 19);
this.label2.TabIndex = 7;
this.label2.Text = "Longitude";
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.SystemColors.ControlText;
this.label1.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.ForeColor = System.Drawing.Color.White;
this.label1.Location = new System.Drawing.Point(193, 223);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(71, 19);
this.label1.TabIndex = 6;
this.label1.Text = "Latitude";
//
// TextBox2
//
this.TextBox2.Location = new System.Drawing.Point(306, 250);
this.TextBox2.Name = "TextBox2";
this.TextBox2.Size = new System.Drawing.Size(156, 20);
this.TextBox2.TabIndex = 5;
this.TextBox2.Text = "67.1150657744";
//
// TextBox1
//
this.TextBox1.Location = new System.Drawing.Point(306, 222);
this.TextBox1.Name = "TextBox1";
this.TextBox1.Size = new System.Drawing.Size(156, 20);
this.TextBox1.TabIndex = 4;
this.TextBox1.Text = "24.9453851704";
//
// button1
//
this.button1.Location = new System.Drawing.Point(287, 302);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 8;
this.button1.Text = "Submit";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label3
//
this.label3.AutoSize = true;
this.label3.BackColor = System.Drawing.SystemColors.ControlText;
this.label3.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.ForeColor = System.Drawing.Color.White;
this.label3.Location = new System.Drawing.Point(491, 9);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(122, 19);
this.label3.TabIndex = 9;
this.label3.Text = "Hammad Khan";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackgroundImage = global::Google.Properties.Resources.google_earth_splash;
this.ClientSize = new System.Drawing.Size(625, 398);
this.Controls.Add(this.label3);
this.Controls.Add(this.button1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.TextBox2);
this.Controls.Add(this.TextBox1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Google Earth Latitude & Longitude";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox TextBox2;
private System.Windows.Forms.TextBox TextBox1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label3;

}
}

Form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Xml;
using System.Diagnostics;

namespace Google
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
String filename = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
filename = filename + @"\latlon.kml";
XmlDocument doc = new XmlDocument();
XmlElement docEle = doc.CreateElement("Placemark");
doc.AppendChild(docEle);

XmlElement root = doc.DocumentElement;

XmlElement infoEle = doc.CreateElement("LookAt");
XmlElement nameEle = doc.CreateElement("latitude");
XmlElement responseEle = doc.CreateElement("longitude");

infoEle.AppendChild(nameEle);
nameEle.InnerText = TextBox1.Text;
infoEle.AppendChild(responseEle);
responseEle.InnerText = TextBox2.Text;

root.AppendChild(infoEle);

doc.Save(filename);

Process.Start(filename);
}
}
}

click-here fot download