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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top