Fortran Hide User Input in FORTRAN 95: Solve Password Problem

  • Thread starter Thread starter dawilso9
  • Start date Start date
  • Tags Tags
    Fortran
AI Thread Summary
To achieve password input without displaying the characters on the screen, it is necessary to utilize routines from the operating system or a GUI library, as standard programming languages like Fortran do not support this functionality directly. The basic approach involves continuously reading keystrokes without requiring the user to press return, while displaying a placeholder (like asterisks) on the screen. This requires handling various key inputs, including letters, numbers, and special keys like backspace. For enhanced security, a robust implementation would involve using a GUI library that manages these low-level details and returns an encrypted version of the password instead of the plaintext input, ensuring that the actual password remains hidden from the program itself.
dawilso9
Messages
1
Reaction score
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
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.
 
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Back
Top