Hide User Input in FORTRAN 95: Solve Password Problem

  • Fortran
  • Thread starter dawilso9
  • Start date
  • Tags
    Fortran
In summary, the user is asking for a way to hide or replace the characters they enter for a password to prevent others from seeing it. This is not a standard feature in Fortran or any other language and would require calling routines from the computer's operating system or a GUI library. The suggested method involves storing the characters in a string and displaying a * on the screen for each character entered, but more complex code would be needed to handle different keystrokes. In a secure system, the password may even be encrypted before being passed to a validation routine.
  • #1
dawilso9
1
0
This might be a stupid question but my TAs in my lab could not answer it so I thought I would try to ask it here. What I want to do is for the user to enter some string of characters for something such as a password and for the input not to show up on the screen or for it to be replaced by something else so someone else cannot see what they previously entered.

Here is what I am asking:

Password: (User enters something)

What I want it to show as it is entered:

Password: (blank) or *********

I hope this is possible I have attempted to find the answer in my book and by googling it but to no avail. Thank you for any help you can provide.
 
Technology news on Phys.org
  • #2
This is not part of "standard" Fortran (or any other language).

You need to call some routines that are part of your computer's operating system, or from a GUI (Graphical user interface) library, to do this.

Probably the "lowest level" way to do it would be code that does something like this:

do while (.true.)

call a routine to read a single keystroke, without the user having to press return, and without displaying anything on the screen

if the keystroke was "return", exit the loop
else store the character in a string, and display a * on the screen.
endinf
enddo

"Real" code to do this would be more complicated, because you need to handle what happens if the user pressed say a function key instread of a letter or number, what to do if the user presses the backspace key, etc, etc. A GUI library would probably include a routine that handles all this low-level stuff and just returns you the string.

Actually, in a really secure system, the GUI routine would not even return you the string that was typed, but an encrypted representation of it. You could pass the encrypted string to another routine to check if the password is valid, without your program ever being able to "see" what the real password was and "steal" it.
 

FAQ: Hide User Input in FORTRAN 95: Solve Password Problem

1. How can I hide user input in FORTRAN 95?

To hide user input in FORTRAN 95, you can use the GET command followed by an asterisk (*). This will prevent the user's input from being displayed on the screen.

2. Can I use the GET command to solve a password problem in FORTRAN 95?

Yes, you can use the GET command to solve a password problem in FORTRAN 95 by using it to hide the user's input when entering a password. This will prevent the password from being displayed on the screen, providing a more secure solution.

3. Are there any other methods for hiding user input in FORTRAN 95?

Yes, there are other methods for hiding user input in FORTRAN 95. You can also use the KEYBOARD command to disable echoing of user input or use the INVISIBLE keyword when declaring input variables.

4. Can I use the GET command in all versions of FORTRAN?

No, the GET command is specific to FORTRAN 95 and is not available in all versions of FORTRAN. However, other methods such as the KEYBOARD command can be used in older versions of FORTRAN to achieve similar functionality.

5. How can I ensure the security of passwords in my FORTRAN 95 program?

In addition to using the GET command to hide user input, you can also use other security measures such as setting maximum password lengths, performing input validation, and encrypting passwords before storing them in the program. It is important to regularly review and update your security measures to ensure the safety of sensitive information in your program.

Similar threads

Replies
14
Views
32K
Replies
4
Views
1K
Replies
16
Views
3K
Replies
59
Views
9K
Replies
4
Views
2K
Replies
3
Views
2K
Back
Top