C command-line password input

后端 未结 7 826
长情又很酷
长情又很酷 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
    <type something><enter>
    > echo $x
    <whatever you typed>
    
    0 讨论(0)
提交回复
热议问题