當前位置:首頁 » 密碼管理 » 如何隱藏c語言密碼
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

如何隱藏c語言密碼

發布時間: 2022-09-21 08:05:37

❶ 在c語言中怎麼樣讓輸入的數字隱藏呢

推薦一個方法,就是一個一個字元的讀入,輸入字元立馬讀入。getchar()函數。
讀取了字元就立馬輸出一個
'\b'退格符,再輸出一個'*'覆蓋,這樣就實現了數字的隱藏。

❷ c語言,怎麼把輸入的數字像密碼一樣隱藏輸出星號啊

#include<stdio.h>
#defineMAX_STR_LEN32

charpasswd[MAX_STR_LEN]={0};

char*GetPasswd(void)
{
charc;
inti=0;
intlen=MAX_STR_LEN-1;

while((c=getch())!=' ')
{
passwd[i]=c;
putchar('*');
i++;
if(i>=len)
{
break;
}
}

returnpasswd;
}

intmain(void)
{
char*dispstr=NULL;

dispstr=GetPasswd();
printf(" thepasswordis:%s ",dispstr);

return0;
}

❸ c語言如何隱藏登陸密碼

#include<conio.h> //這個頭文件不是標准庫函數的,一般編譯器是有的,但是 unix和linux編譯器是沒有的
#define PASSWORD "123456"

int password()
{
char
p[20],i=0;
system("cls");
printf("請輸入密碼 => ");

while(p[i]=getch())
{
if(p[i]==13)
break;
if(p[i]!='\b')
{
printf("*");
i++;
}
else
{
printf("\b
\b");
i--;
}
}
p[i]='\0';

if(strcmp(p,PASSWORD)==0)

{
printf("驗證通過");
press();
return 1;

}
else

{
printf("密碼錯誤");
press();
return 0;

}
}

❹ 最新的Linux下的c語言怎麼隱藏輸入的登錄密碼,並回顯為* 不要getch()它沒用

在linux中getch可以做到不回顯,但是用法比windos中復雜一點點,以下是簡單實現,密碼設為6位,可以按退格修改,就只寫了這些功能,望採納
#include<stdio.h>
#include<curses.h>
int main()
{
int i,j=0;
char ch;
initscr();
cbreak();
noecho();
curs_set(0);
for(i=0;i<6+2*j;i++)
{
ch=getch();
addstr("*");
if(i)
{
if(ch==127)
{
j++;
move(0,i+1-2*j);
clrtoeol();
}
}
}
getch();

endwin();
return 0;
}

❺ C語言隱藏從鍵盤輸入的密碼串中第一個字元以外的所有字元

void HideCipher (char t[], char s[])
{
int i,j;
t[0]=s[0];
for (i=1; s[i]!='\0'; i++)
t[i]='*';

t[i]='\0';
}

❻ C語言 如何不回顯密碼

#include <unistd.h>
#include<stdio.h>
#include <termios.h>
char Getch()
{
char ch;
struct termios oldt, newt;

tcgetattr(STDIN_FILENO, &oldt);
newt = oldt;
newt.c_lflag &= ~(ECHO|ICANON);
tcsetattr(STDIN_FILENO, TCSANOW, &newt);
ch = getchar();
tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
return ch;
}
void getpasswd(char *p)
{
int i=0;
printf("password:");

while((*(p+i)=Getch())!='\n')
{
putchar('*');
i++;
}
*(p+i) = '\0';
}
int main()
{
char a[10];
getpasswd(a);
printf("%s",a);
}

❼ C語言將密碼設為隱身形式該使用什麼函數

輸入的時候隱藏密碼顯示星號'*'的功能吧?

沒有直接可調用的函數,用getch(),這個函數讀取字元不顯示,然後每讀取一個字元後面跟著輸出一個『*』

#include<stdio.h>
intmain()
{
charc;
while(1)
{
c=getch();
if(c!=' ')
putchar('*');
else
break;
}
}

❽ linux系統下用C語言編了個下程序,不知道如何在輸入密碼時隱藏,只顯示「*」,求大神們幫幫忙啊 !!!

函數名: getch
功 能: 從控制台無回顯地取一個字元
用 法: int getch(void);

#include<conio.h>
#include<stdio.h>
intmain(void)
{
charp[50];
inti=-1;
do{
++i;
p[i]=getch();
putchar('*');

}while(p[i]!=13);//13為回車ascii
p[i+1]='';//最後添加字元串結尾
putchar(' ');
puts(p);
return0;
}

❾ c語言怎麼隱藏輸入的數字

在windows平台上調用getch()函數即可。在linux平台下時(即包含的是curses.h),還應該在使用函數之前使用initscr(),使用完畢之後調用endwin().否則的話不需輸入就會返回。以windows為例:

#include<stdio.h>
#include<conio.h>
intmain()
{
charch=getch();
printf("getch輸入看不到,printf知道輸入的是:%c ",ch);
return0;
}

❿ 大師好:可以告訴我怎麼寫一個C++登陸密碼隱藏程序嗎在下萬分感謝……!!!

幫你改了下pass(),有很多問題,界面有些亂不過還是留給你自己改吧,我把int類型的改成了char型int pass()
{
int i,j,n;
char t[M];
char password[]={"1234"};
for(n=0;n<3;n++)
{
cout<<"\t\t請輸入密碼"<<endl;
t[0]='\0';
j=0;
t[j]=getch();
while(t[j]!=13&&j<M)
{
cout<<'*';
j++;
t[j]=getch();
}
cout<<endl;
t[j]='\0';
//cout<<password<<endl;
//cout<<t<<endl;
if(!strcmp(t,password))
return 1;
else
cout<<"您輸入的密碼錯誤,請重新輸入"<<endl;
}
getch();
return 0;
}