• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Password encripting

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I want to hardcode to the password field. Please help me for that.
I am enclosing my code here.


//Gopal Das


[edit]Add code tags. CR[/edit]
[ July 31, 2008: Message edited by: Campbell Ritchie ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean by hardcode? If you don't want the user to enter a password, then don't let him enter it. You can use a String constant instead.

As an aside, having two sets of fields called username/password/hostname is bound to cause trouble at some point. Consider removing one of them.
 
Gopal krushna Das
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
But i need to put password.One thing when i am entering the password this password is clearly visible for anyone. But i need when i enter password it should not be show and it will show ******** like that.Please change in my code.
//Gopal Das


import com.jscape.inet.ftp.*;
import java.io.*;
import java.util.Enumeration;

public class FtpMuploadExample extends FtpAdapter {
private String hostname;
private String username;
private String password;

// perform multiple file upload
public void doUpload(String hostname, String username, String password) throws FtpException {
Ftp ftp = new Ftp(hostname,username,password);

//capture Ftp related events
ftp.addFtpListener(this);
ftp.connect();
ftp.setBinary();
ftp.mupload(".*\\MUT*.*");
ftp.disconnect();
}

// captures upload event
public void upload(FtpUploadEvent evt) {
System.out.println("Uploaded file: " + evt.getFilename());
}

// captures connect event
public void connected(FtpConnectedEvent evt) {
System.out.println("Connected to server: " + evt.getHostname());
}

// captures disconnect event
public void disconnected(FtpDisconnectedEvent evt) {
System.out.println("Disconnected from server: " + evt.getHostname());
}


public static void main(String[] args) {
String hostname ;
String username;
String password;
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter Ftp hostname : ");
hostname = reader.readLine().trim();
System.out.print("Enter username : ");
username = reader.readLine().trim();
System.out.print("Enter password : ");
password = reader.readLine().trim();
System.out.println("Using upload filter .*\\MUT*.*");
FtpMuploadExample example = new FtpMuploadExample();
example.doUpload(hostname,username,password);
}
catch(Exception e) {
e.printStackTrace();
}
}
}
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


But i need to put password.One thing when i am entering the password this password is clearly visible for anyone. But i need when i enter password it should not be show and it will show ******** like that.


Do you mean when you type the password in the command line you want it to appear as *****?
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Please change in my code.

No. People here won't (and SHOULDN'T) do your work for you.

folks around here will bend over backwards to HELP YOU LEARN, and figure it out yourself. they'll point you in the right direction, give you tips and suggestions, make subtle corrections...

if you want somebody to write your code for you, i suggest you post under "jobs offered" and provide decent compensation.

otherwise... if you are having the user input the password from the command line, there's not much you can do (That i'm aware of). it's an OS problem, not a java problem.

you could create a pop-up type window for entering a password - java supports the "*"s for that.
 
Sheriff
Posts: 22791
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or use java.io.Console - available through System.console() since Java 6.

Keep in mind that System.console() will return null if no console is available, for instance when run from an IDE.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic