#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define USERNAME admin
#define PASSWORD admin
#define KEY 5
char * Encrypt(char password[]); //加密
char * DeEncrypt(char password[]); //解密
int main()
{
char name[50];
printf("请输入您的密码:");
fgets(name,40,stdin);
printf("加密后的密码是:%s",Encrypt(name));
printf("\n解密后的密码是:%s",DeEncrypt(name));
return 0;
}
char * Encrypt(char password[])
{
int count;
int i=0;
count = strlen(password);
for(;i<count;i++)
{
password[i] = password[i] +i +KEY;
}
return password;
}
char * DeEncrypt(char password[])
{
int count;
int i=0;
count = strlen(password);
for(;i<count;i++)
{
password[i] = password[i] -i -KEY;
}
return password;
}
实现字符串的加密与解密
猜你喜欢
转载自blog.csdn.net/qq_37796444/article/details/82529782
今日推荐
周排行