Login module with password encryption

Login module with password encryption funtionality

Page 1 of 1

6 Replies - 14954 Views - Last Post: 05 October 2009 - 03:40 PM Rate Topic: -----

#1 flavus310   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 28-September 09

Login module with password encryption

Post icon  Posted 05 October 2009 - 04:06 AM

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Login.java
 *
 * Created on Sep 7, 2009, 11:29:51 PM
 */

package mylogin;

import java.io.File;
import java.io.FileReader;
import java.util.Scanner;
import javax.swing.JOptionPane;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.Timer;
import java.awt.event.*;

/**
 *
 * @author Admin
 */
public class Login extends javax.swing.JFrame {



	/** Creates new form Login */
	public Login() {
		initComponents();
		//init your here
	   // Timer t;
		t = new Timer(1000, new ActionListener(){
				 public void actionPerformed(ActionEvent e){
					Date now = new Date();
					SimpleDateFormat myFormat = new SimpleDateFormat(" EEE, MMM d ''yy, hh:mm:ss a");
				 l_DateTime.setText(myFormat.format(now));
				}
			});
		 t.start();
	}
 
	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
	private void initComponents() {

		jPanel1 = new javax.swing.JPanel();
		l_Username = new javax.swing.JLabel();
		l_Password = new javax.swing.JLabel();
		t_UserName = new javax.swing.JTextField();
		jPanel2 = new javax.swing.JPanel();
		jLogin = new javax.swing.JButton();
		jSignUp = new javax.swing.JButton();
		jExit = new javax.swing.JButton();
		jReset = new javax.swing.JButton();
		l_Info = new javax.swing.JLabel();
		l_DateTime = new javax.swing.JLabel();
		t_Password = new javax.swing.JPasswordField();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		setTitle("LOGIN");
		setBounds(new java.awt.Rectangle(0, 0, 0, 0));
		setResizable(false);

		jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Please Login", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial Black", 0, 13))); // NOI18N

		l_Username.setFont(new java.awt.Font("Arial Black", 0, 12));
		l_Username.setText("User Name:");

		l_Password.setFont(new java.awt.Font("Arial Black", 0, 12));
		l_Password.setText("Password:");

		jLogin.setFont(new java.awt.Font("Arial Black", 0, 11));
		jLogin.setText("Login");
		jLogin.setPreferredSize(new java.awt.Dimension(75, 30));
		jLogin.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jLoginActionPerformed(evt);
			}
		});

		jSignUp.setFont(new java.awt.Font("Arial Black", 0, 11));
		jSignUp.setLabel("SignUp");
		jSignUp.setPreferredSize(new java.awt.Dimension(75, 30));
		jSignUp.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jSignUpActionPerformed(evt);
			}
		});

		jExit.setFont(new java.awt.Font("Arial Black", 0, 11));
		jExit.setText("Exit");
		jExit.setPreferredSize(new java.awt.Dimension(70, 30));
		jExit.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jExitActionPerformed(evt);
			}
		});

		jReset.setFont(new java.awt.Font("Arial Black", 0, 11));
		jReset.setText("Reset");
		jReset.setPreferredSize(new java.awt.Dimension(70, 30));
		jReset.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jResetActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
		jPanel2.setLayout(jPanel2Layout);
		jPanel2Layout.setHorizontalGroup(
			jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
			.addGroup(jPanel2Layout.createSequentialGroup()
				.addContainerGap()
				.addComponent(jLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
				.addComponent(jSignUp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
				.addComponent(jReset, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
				.addComponent(jExit, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
				.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
		);
		jPanel2Layout.setVerticalGroup(
			jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
			.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
				.addComponent(jLogin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
				.addComponent(jSignUp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
				.addComponent(jReset, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
				.addComponent(jExit, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
		);

		jLogin.getAccessibleContext().setAccessibleName("login_button");
		jSignUp.getAccessibleContext().setAccessibleName("jSignUp");
		jExit.getAccessibleContext().setAccessibleName("jExit");
		jReset.getAccessibleContext().setAccessibleName("jReset");

		javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
		jPanel1.setLayout(jPanel1Layout);
		jPanel1Layout.setHorizontalGroup(
			jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
			.addGroup(jPanel1Layout.createSequentialGroup()
				.addGap(42, 42, 42)
				.addComponent(l_Info, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
				.addComponent(l_DateTime, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
				.addGap(27, 27, 27))
			.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
				.addContainerGap(87, Short.MAX_VALUE)
				.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
					.addGroup(jPanel1Layout.createSequentialGroup()
						.addComponent(l_Password, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
						.addGap(18, 18, 18)
						.addComponent(t_Password, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE))
					.addGroup(jPanel1Layout.createSequentialGroup()
						.addComponent(l_Username, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
						.addGap(18, 18, 18)
						.addComponent(t_UserName, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE)))
				.addGap(70, 70, 70))
			.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
				.addContainerGap(58, Short.MAX_VALUE)
				.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
				.addGap(31, 31, 31))
		);
		jPanel1Layout.setVerticalGroup(
			jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
			.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
				.addGap(72, 72, 72)
				.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
					.addComponent(t_UserName, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
					.addComponent(l_Username, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
				.addGap(18, 18, 18)
				.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
					.addComponent(l_Password, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
					.addComponent(t_Password, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
				.addGap(40, 40, 40)
				.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
				.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
					.addComponent(l_Info, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
					.addComponent(l_DateTime, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
				.addGap(28, 28, 28))
		);

		l_Username.getAccessibleContext().setAccessibleName("l_UserName");
		l_Password.getAccessibleContext().setAccessibleName("jPassword:");
		t_UserName.getAccessibleContext().setAccessibleName("t_UserName");
		l_Info.getAccessibleContext().setAccessibleName("authLabel");
		l_DateTime.getAccessibleContext().setAccessibleName("timeLabel");
		t_Password.getAccessibleContext().setAccessibleName("jPassword");

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(
			layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
			.addGroup(layout.createSequentialGroup()
				.addContainerGap()
				.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
				.addContainerGap())
		);
		layout.setVerticalGroup(
			layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
			.addGroup(layout.createSequentialGroup()
				.addContainerGap()
				.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
				.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
		);

		getAccessibleContext().setAccessibleName("jFrame");

		pack();
	}// </editor-fold>//GEN-END:initComponents

	private void jSignUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jSignUpActionPerformed
		this.setVisible(false);
		new SignUp(this,true).setVisible(true);
	  this.setVisible(true);
	}//GEN-LAST:event_jSignUpActionPerformed

	private void jExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jExitActionPerformed
  
	 System.exit(0);
	}//GEN-LAST:event_jExitActionPerformed

   private void jResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jResetActionPerformed

	 t_UserName.setText("");
	 t_Password.setText("");

   
   }//GEN-LAST:event_jResetActionPerformed
private void jLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jLoginActionPerformed
	String user =t_UserName.getText();
	String pass =String.valueOf(t_Password.getPassword());
	if(user.equals("") | pass.equals("")){
		JOptionPane.showMessageDialog(this,"Requires All Fields");
	}else{
		//file checking begins
		Scanner input;
	   // input = new Scanner
}//GEN-LAST:event_jLoginActionPerformed
}
 
  
   
	   // 
		// @param args the command line arguments
   
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new Login().setVisible(true);
				  //t.start();
			}
		});
		
	}
	// Variables declaration - do not modify//GEN-BEGIN:variables
	javax.swing.JButton jExit;
	javax.swing.JButton jLogin;
	javax.swing.JPanel jPanel1;
	javax.swing.JPanel jPanel2;
	javax.swing.JButton jReset;
	javax.swing.JButton jSignUp;
	javax.swing.JLabel l_DateTime;
	javax.swing.JLabel l_Info;
	javax.swing.JLabel l_Password;
	javax.swing.JLabel l_Username;
	javax.swing.JPasswordField t_Password;
	javax.swing.JTextField t_UserName;
	// End of variables declaration//GEN-END:variables
	 Timer t;
}


Edited by Locke. In the future, please :code:.

This post has been edited by Locke: 05 October 2009 - 08:16 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Login module with password encryption

#2 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12362
  • View blog
  • Posts: 45,476
  • Joined: 27-December 08

Re: Login module with password encryption

Posted 05 October 2009 - 05:39 AM

:code:

Also, please describe the problem you are experiencing.
Was This Post Helpful? 0
  • +
  • -

#3 olibenu   User is offline

  • D.I.C Addict
  • member icon

Reputation: 45
  • View blog
  • Posts: 538
  • Joined: 31-December 08

Re: Login module with password encryption

Posted 05 October 2009 - 07:59 AM

if its a code we can use, add it as a snippet
Was This Post Helpful? 0
  • +
  • -

#4 NeoTifa   User is online

  • NeoTifa Codebreaker, the Scourge of Devtester
  • member icon





Reputation: 4305
  • View blog
  • Posts: 18,652
  • Joined: 24-September 08

Re: Login module with password encryption

Posted 05 October 2009 - 08:09 AM

Ugh, looks like the work of a GUI builder to me.... is there a problem with it?
Was This Post Helpful? 0
  • +
  • -

#5 Locke   User is offline

  • Sarcasm Extraordinaire!
  • member icon

Reputation: 550
  • View blog
  • Posts: 5,624
  • Joined: 20-March 08

Re: Login module with password encryption

Posted 05 October 2009 - 08:16 AM

Please remember to :code:. I edited your post for you, but just please do it yourself.

And, what exactly is your problem?

(and yes, NeoTifa, it is indeed the NetBeans GUI builder)

This post has been edited by Locke: 05 October 2009 - 08:18 AM

Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12362
  • View blog
  • Posts: 45,476
  • Joined: 27-December 08

Re: Login module with password encryption

Posted 05 October 2009 - 09:46 AM

Encryption is really a simple subject. What happens is, the user enters the plaintext to be encrypted. This encrypted text, called ciphertext, is then stored in the database. When the users try to login, the ciphertext of the plaintext entered is tested against the stored ciphertext. If the two ciphertext Strings do not equal each other, then the passwords entered are not the same. As to the problem you are having with your program, could you please describe it?
Was This Post Helpful? 0
  • +
  • -

#7 pbl   User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8379
  • View blog
  • Posts: 31,956
  • Joined: 06-March 08

Re: Login module with password encryption

Posted 05 October 2009 - 03:40 PM

View Postolibenu, on 5 Oct, 2009 - 06:59 AM, said:

if its a code we can use, add it as a snippet

Please.... do not post GUI generated code in the Snippet
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1