getpass 函式 螢幕輸入不回顯

2021-09-30 12:27:19 字數 617 閱讀 8744

環境:vmware workstation;centos-6.4-x86_64

說明:

讀寫使用者輸入,螢幕不回顯

char *getpass( const char *prompt);

getpass用於從鍵盤讀取使用者輸入,但螢幕不回顯。

引數prompt為螢幕提示字元。

函式返回值為使用者鍵盤輸入的字串。

螢幕不回顯指的是,使用者輸入的內容,不會顯示任何提示資訊,就是在linux中切換使用者時,輸入密碼不現實一樣。

程式如下:

#include #include int main(int argc, char *args)

編譯並執行程式:

[negivup@negivup mycode]$ gcc -o main main.c

[negivup@negivup mycode]$ ./main

input your password : ------------這裡輸入內容不會回顯

password = 123456

getpass密碼輸入模組

getpass是python的內建模組,其api解釋如下 可以看到,getpass的第乙個方法getpass可以在命令列視窗裡面無回顯輸入密碼。引數prompt代表提示字串,預設是 password 在linux系統中,stream預設為當前控制的終端。在windows系統裡stream引數會被忽略...

注意getpass 函式

getpass 函式用來接收密碼,無回顯 函式原型 include char getpass const char prompt 引數prompt時輸入時的提示資訊,返回 char 我自己使用時遇到這種問題 include include include int main void 結果 passw...

Unix 不回顯輸入密碼

原帖見 http blog.163.com xiaolei li blog static 114404451200911172155783 在軟體開發中,往往會遇到要求使用者輸入密碼的情況。出於對密碼的保密,輸入的字元是不會顯示到螢幕上的。例如,在登入linux系統時,輸入使用者名稱後,輸入的密碼是...