C program to achieve Password Input linux system executable, hidden linux

Source: Internet
Author: User

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:

  1. [Negivup @ negivup mycode] $ gcc-o main. c
  2. [Negivup @ negivup mycode] $./main
  3. Input your password: ------------ the Input content is not displayed
  4. Password = 123456

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.