Forum Home
Press F1
 
Thread ID: 53105 2005-01-07 10:39:00 Are there any programmer!?!? ocmara (6659) Press F1
Post ID Timestamp Content User
311734 2005-01-07 10:39:00 Hi,
I found a good article which Illustrated or actually had a nice code to hide password but it doesn't working well! Could you tell me why?
the code in java.sun.com
Or give me any suggestions to do that "Hide password letter when the user typed from console windows" ?!

Thanks
ocmara (6659)
311735 2005-01-07 11:13:00 That doesn't make a whole lot of sense to me. Could you be a bit more specific as to what you are wanting to do? ninja (1671)
311736 2005-01-07 13:29:00 If you are not an English speaking person then I am sorry otherwise please learn how to communicate, because that lot was double dutch. mikebartnz (21)
311737 2005-01-07 18:11:00 Sorry for confusing you,

Could you tell me why the code in this link does’t works well!?!?!?
java.sun.com

Thank you and sorry again :o
ocmara (6659)
311738 2005-01-07 20:12:00 Are you trying to program something in JAVA?

What are you trying to do with that code - implementation is the key.

And no one can tell you why your specific code problem won't work without seeing the code in question.
ninja (1671)
311739 2005-01-07 20:12:00 ocmara
Those are code snippets (examples). Also if you are trying to use those snippets, (as written there) in Javascript they may not work as those examples provided are for Java applets. The syntax of lanuage changes between script and applet versions of Java that is maybe why you are having problems.
Also using javascript as a means of password protecting a page is very insecure, anyone with some basic knowledge can view the password. There other ways that are just as easy to implement and although not highly secure will do the the trick or you could all the way and implement a linux solution, it depends on what you are trying to protect and how valuable it is to you.
beama (111)
311740 2005-01-08 11:01:00 Hi beama,
I fixed that code it is running on my machine now, but it has some bugs.
Now I need some one tell me what is wrong with it or give me any Idea to do this task (Hide password’s letter from user like all password which we always deal with them)!!!!

Thank you so much!
ocmara (6659)
311741 2005-01-09 18:22:00 Are you try to code a java applet or are you using Javascript?, you haven't said.
As prevously stated its hard to debug code if you are unable to see it, if you what us to help with this please post the code here so we can look at it.
There are some very knowledable people here.
Also a search on google for "javascript password scripts" may give you some ideas on how to get that that password hashing to work.
With java, in my experance when the debugger throws an error with a line number always look a couple lines before the line the debugger says because more than likly it is an error caused by a flow on effect of error in logic in previous lines.
beama (111)
311742 2005-01-10 12:53:00 This is the code which give me infinite loop of those  ************ :badpc:


package com . aramco . ecn . sapwm;

import java . io . *;

/**
* Created on Feb 21, 2003
*/
public class HidePasswordFromCommandLine extends Thread {
boolean stopThread = false;
boolean hideInput = false;
boolean shortMomentGone = false;

public void run()
{
try
{
sleep(500);
}
catch (InterruptedException e) { }
shortMomentGone = true;
while (!stopThread)
{
if (hideInput)
{
System . out . print("\b* ");
}
try
{
sleep(1);
} catch (InterruptedException e) { }
}
}

public static void main(String[] arguments)
{
String name = "";
String password = "";
HidePasswordFromCommandLine hideThread = new HidePasswordFromCommandLine();
hideThread . start();
BufferedReader in = new BufferedReader(new InputStreamReader(System . in));
try
{
System . out . println("Name: ");
// Wait for the username and clear the keyboard buffer (if neccessarry)
do
{
name = in . readLine();
} while (hideThread . shortMomentGone == false);
// Now the hide thread should begin to overwrite any input with "*"
hideThread . hideInput = true;
// Read the password
System . out . println("\nPassword: ");
System . out . print(" ");
password = in . readLine();
hideThread . stopThread = true;
} catch (Exception e) { }
System . out . print("\b \b ");
// JUST FOR TESTING - PLEASE DELETE!
System . out . println("\n\nLogin= " + name);
System . out . println("Password= " + password);
}
ocmara (6659)
311743 2005-01-10 17:59:00 while (hideThread.shortMomentGone == false);

you never reset the shortMomentGone to true therefore you will never exit that loop
beama (111)
1 2