Jack's Blog

流淌的心,怎能阻拦,吹来的风,又怎能阻挡。

暗文密码输入系统

Jacob posted @ May 25, 2017 12:33:25 PM in C语言 with tags password system 隐藏密码 C语言 , 734 阅读

Write before:

Have you ever feel amazed when you settle to think about the principles when you entering your password?

I haver always been curious about that.

So lets' uncover the mystery now!


#include <stdio.h>
#include <conio.h>
#define MAX_PSD_LEN 20

char PassWord[MAX_PSD_LEN],*p=PassWord,ch;
int count=0;
 main()
{
    ch=getch();
    while(ch!=13&&count<MAX_PSD_LEN-1)       /*当按下回车键或密码长度达到19,则退出循环*/
    {
        if(ch==8)                       /*如果按下的是向前删除键,则...*/
        {
            if(count)              /*如果密码串中字符数大于零,则向前删除一个字符*/
            {
                p--;
                count--;
                printf("\b ");/*光标回退一格,将星号(*)改为空格*/
                printf("\b"); /*光标重新回退一格*/
            }
        }
        else if((ch<='Z'&&ch>='A')||(ch<='z'&&ch>='a')||(ch<='9'&&ch>='0'))
                                                  /*如果输入的是密码的有效字符*/
        {
            printf("*");          /*输出一个星号*/
            count++;
            *p=ch;                /*记录密码内容*/
            p++;
        }
        ch=getch();                    /*等待输入下一个字符*/
    }
    PassWord[count]=0;
    printf("\nThe Password you input is:\n");
    printf("%s\n",PassWord);
}


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter