Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

Authentication of password

Ads

 
 

Share on Google+Share on Google+

manjiri
Authentication of password
4 Answer(s)      8 years ago
Posted in : Swing AWT
Ads
View Answers

December 16, 2008 at 7:04 AM


check out the below link


December 17, 2008 at 12:39 AM




December 17, 2008 at 6:08 AM


Hi friend,



I am sending running code, please implement this code.

import java.io.*;
import javax.crypto.Cipher;
import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGenerator;
import java.security.Key;
import java.security.InvalidKeyException;

public class EncryptData {
private static String algo = "DESede";

private static Key genkey = null;

private static Cipher cipher = null;



private static void setUp() throws Exception {

genkey = KeyGenerator.getInstance(algo).generateKey();

cipher = Cipher.getInstance(algo);

}





public static void main(String args[]) throws Exception {

String str = "";
setUp();

if (str ==null && str=="") {

System.out.println("Please enter String.");

System.exit(1);

}

byte[] enByte = null;

String inputStr = args[0];

System.out.println("Entered: " + inputStr);

enByte = enDt(inputStr);

String str1 = enByte.toString();

String str2 = dedt(enByte).toString();

System.out.println("Input String: " + inputStr);

System.out.println("Encrypt code: " + str1);

System.out.println("Decrypt code: " + str2);
}



private static byte[] enDt(String inputStr)

throws Exception {

cipher.init(Cipher.ENCRYPT_MODE, genkey);

byte[] inputStrBytes = inputStr.getBytes();

return cipher.doFinal(inputStrBytes);

}



private static String dedt(byte[] enByte)

throws Exception{

cipher.init(Cipher.DECRYPT_MODE, genkey);

byte[] recByte = cipher.doFinal(enByte);

String recovered = new String(recByte);

return recovered;

}

}

-----------------------------------

Thanks.


December 17, 2008 at 6:40 AM


I am sending running code. If you have any problem then explain in detail.


import java.io.*;

public class PasswordField {

public static String readPassword(String prompt) {
EraserThread eraser = new EraserThread(prompt);
Thread mask = new Thread(eraser);
mask.start();

BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String password = "";

try {
password = in.readLine();
}
catch(IOException ioe) {
ioe.printStackTrace();
}
// stop masking
eraser.stopMasking();
// return the password entered by the user
return password;
}
}

-----------------------------------------

import java.io.*;

class EraserThread implements Runnable {
private boolean stop;

// The prompt displayed to the user

public EraserThread(String prompt) {
System.out.print(prompt);
}

//Begin masking display asterisks (*)

public void run () {
stop = true;
while(stop) {
System.out.print("\010*");
try {
Thread.currentThread().sleep(1);
}
catch(InterruptedException ie) {
ie.printStackTrace();
}
}
}

//Instruct the thread to stop masking

public void stopMasking() {
this.stop = false;
}
}
------------------------------------------

public class TestApp {
public static void main(String args[]) {
String pwd = PasswordField.readPassword("Enter password: ");
System.out.println("The password entered is: "+pwd);
}
}
--------------------------------------

Visit for more information.

http://www.roseindia.net/java/example/java/swing/

Thanks.

Ads









Related Tutorials/Questions & Answers:
Authentication of password - Swing AWT
Authentication of password  System level authentication of password.... How the Printed password gets converted into the asteric (*) mark... BufferedReader(new InputStreamReader(System.in)); String password
Basic authentication
Basic authentication       Basic authentication is the process through which a web server authenticates an entity with a user name and password received by the user by using
Advertisements
Password
Password  make a program which ask ask the username and password * in this format. in C language
PHP User Authentication Login and password check Tutorial
to the database. $dbname="name"; #Password to verify its you. $dbpass="
Authentication - JavaMail
Authentication program in Java  How to write a program in Java for user authentication
Authentication in Servlets
Authentication in Servlets  What are different Authentication options available in Servlets
Authentication - Struts
Authentication  Hello everybody, How to provide high level authentication in struts application
Login authentication
Login authentication  i want d code for login authentication from mysql database on the same pc using swings
Login authentication
Login authentication  i want d code for login authentication from mysql database on the same pc using swings
gmail authentication
browser window it asks for authentication how it is possible if anybody knows plz tell... request Authentication done using Session If you signout and paste URL It Ask
Sending email without authentication
Sending email without authentication  Hi sir, Am doing a project in JSP, in that i want to send mail without any authentication of password so send me code as soon as possible.   Please visit the following links
Login Authentication using existing Active Directory.
Login Authentication using existing Active Directory.  I need jsp code for login authentication of username and password using already existing... be Such that there should be no inputs for code other than username, password and LDAP
iphone nsurlrequest authentication
iphone nsurlrequest authentication   How to authenticate a form in iPhone Application
forgot password?
forgot password?  forgot password
windows authentication with hibernate - Hibernate
windows authentication with hibernate  Does anyone know how to setup a datasource for SQL Server that uses Windows authentication instead of SQL Server mixed mood authentication? Is it possible with hibernate framwork? Thanks
SSL Authentication - JSP-Servlet
SSL Authentication  With the help of a sample code describe the use of SSL Authentication of java clients
password check
password check  how to check sighup passowrd and login password
Java Glossary : Authentication
Java Glossary : Authentication       Authentication is the process of ensuring to some in order... it claims to be. This types of services works on shared secrets like password
JDbc Login Authentication
Authentication Using ComboBox.From Servlet and jsp with sessions I am new to sessions...;<td align="left">Password:</td><td><input type="password" name="password" size="20"></td></tr> <tr><td align
http Client Authentication
authentication problem. can any one please help me to solve this problem. please... UserId="adm"; String Password="adm"; String postTitle="Pls11...().encode((UserId+":"+Password).getBytes()))); System.out.write(entry
login authentication in jsp and servlet
login authentication in jsp and servlet  Hi, I am beginner in web... to make login authentication in jsp and servlet? Thanks   Hi, I to make login authentication in jsp and servlet you have to write code for database
change password
change password  how to change password in the login form.... by giving options to user like this old password, new password.. pls help
Reset Password
Reset Password  coding for reset password
retype password
retype password  coding for retype password
recovery of password through mail
recovery of password through mail  hi i want code for login page authentication in jsp with oracle database.it should be similar to any mail login... user account should be verified and if they forgot password then security question
login authentication - Java Beginners
login authentication  i 've designed the jsp page for login. now i need to connect it with the bean and do authentication for the login for the "register" table in mysql. can anybody help me with the code immediately
forget password?
forget password?  can anyone help me? how to create a module of forget password?the password can reset by generate random password and send to user's email..i develop the php system using xampp and dreamweaver
forget password?
forget password?  can anyone help me? how to create a module of forget password?the password can reset by generate random password and send to user's email..i develop the php system using xampp and dreamweaver
forget password
forget password  codding for forget password using spring framework
Forgot password
Forgot password  hi i want to develop a code for when user clicks on forgot password then the next page should be enter his mobile no then the password must be sent to his mobile no...! Thanks in advance Nag Raj