#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void DecodeShow(char aryPassWord[], char aryCipherText[]);
void EncryptionShow(char aryPassWord[], char aryCipherText[]);
void EncryptionShow(char aryPassWord[], char aryCipherText[])
{
int ndex = 0;
int nLen = strlen(aryPassWord);
for (int i = 0; i < nLen; i++)
{
ndex = i;
aryCipherText[ndex] = aryPassWord[i] + i + 5;
ndex++;
};
aryCipherText[ndex] = '\0';
printf("%s\n", aryCipherText);
};
void DecodeShow(char aryPassWord[], char aryCipherText[])
{
int ndex = 0;
int nLen = strlen(aryPassWord);
for (int j = 0; j < nLen; j++)
{
ndex = j;
aryPassWord[ndex] = aryCipherText[j] - j - 5;
ndex++;
};
aryPassWord[ndex] = '\0';
printf("%s\n", aryPassWord);
};
int main()
{
char aryName[30];
char aryPassWord[16];
char aryCipherText[16];
int nCont = 4;
int nTenp = 0;
int i = 0;
printf("\t\t\t\t\t《《登录程序》》\t\t\t\t\n");
for (i = 0; i <= 3; i++)
{
printf("Please enter your name:\n");
gets_s(aryName,30);
printf("Please enter your password:\n");
gets_s(aryPassWord,16);
printf("\nEnciphered data:\n");
EncryptionShow(aryPassWord,aryCipherText);
printf("\nDecrypt data:\n");
DecodeShow(aryPassWord, aryCipherText);
if ((strcmp("张三", aryName) == 0) && (strcmp("admin", aryPassWord) == 0))
{
printf("登录成功!");
nTenp == 0;
break;
}
else
{
printf("\n\nTypo! Please enter it again\n\n");
printf("\n\n----------------------------------\n\n");
printf("\n\nNumber of errors:%d\n\n", nCont - 1);
nCont--;
};
if (nCont == 0)
{
printf("You have ENTERED YOUR USERNAME and PASSWORD incorrectly 3 times. Please exit the program!\n\n");
};
};
if (nTenp == 1)
{
printf("Please enter your name:\n\n");
gets_s(aryName,30);
printf("Please enter your password \n\n");
gets_s(aryPassWord,16);
};
system("pause");
return 0;
};
登录加密的位移或异或
最新推荐文章于 2024-05-08 15:24:52 发布