C program to achieve Password Input linux system executable, hidden linux
Read/write user input. The screen is not displayed.
Char * getpass (const char * prompt );
Getpass is used to read user input from the keyboard, but the screen is not displayed.
The prompt parameter is the on-screen prompt character.
The Return Value of the function is a string input by the user's keyboard.
If the screen is not displayed, the user-input content does not display any prompt information, that is, when switching users in Linux, the input password is not the same.
The procedure is as follows:
1 # include <stdio. h> 2 # include <unistd. h> 3 4 int main (int argc, char * args []) 5 {6 // call the getpass function 7 // The function parameter is prompted. 8 // the return value of the function is the user Input content 9 char * password = getpass ("Input your password: "); 10 // output user input 11 printf (" password = % s \ n ", password); 12 return 0; 13} 14 15
Compile and execute the program:
- [Negivup @ negivup mycode] $ gcc-o main. c
- [Negivup @ negivup mycode] $./main
- Input your password: ------------ the Input content is not displayed
- Password = 123456