C command-line password input

后端 未结 7 863
长情又很酷
长情又很酷 2020-12-03 15:00

I want to allow users to enter password using command-line interface. but I don\'t want to display this password on screen (or display \"****\").

How to do it in C?

7条回答
  •  北荒
    北荒 (楼主)
    2020-12-03 15:27

    For C/commandline/linux see:

    man getch
    man noecho
    

    see the coment in getch about noecho. I've never tried this myself.

    In bash if you use read -s it does not echo on the screen:

    > read -s x
    
    > echo $x
    
    

提交回复
热议问题