大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
char* encode(const char* str)
目前成都创新互联已为千余家的企业提供了网站建设、域名、网站空间、网站托管、服务器租用、企业网站设计、兴业网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
{
int i, s;
s = 0;
for(i = 0; str[i]; i++) s += str[i] * str[i];
for(i = 0; str[i]; i++) {
if(str[i] = 'a' str[i] = 'z') {
str[i] = (str[i] + s) % 128;
}
}
return str;
}
不能准确地恢复
#include stdio.h
#include ctype.h
char *encrypt(char *text) {
char c;
char *p = text;
for (; *text; ++text) {
c = *text;
if (isdigit(c))
*text = '0' + '9' - c;
else if (islower(c)) {
c = c + 3;
if (c 'z')
c = c - 26;
*text = c;
} else if (isupper(c)) {
c = c + 3;
if (c 'Z')
c = c - 26;
*text = c;
}
}
return p;
}
int main() {
char text[100];
printf("输入明文:");
scanf("%s", text);
printf("密文:%s\n", encrypt(text));
getchar();
}
C语言设计一个简单的加密解密程序如下:
加密程序代码:
#includestdio.h
main()
{
char c,filename[20];
FILE *fp1,*fp2;
printf("请输入待加密的文件名:\n");
scanf("%s",filename);
fp1=fopen(filename,"r");
fp2=fopen("miwen.txt","w");
do
{
c=fgetc(fp1);
if(c=32c=126)
{
c=c-32;
c=126-c;
}
if(c!=-1)
fprintf(fp2,"%c",c);
}
while(c!=-1);
}
解密程序代码:
#includestdio.h
#includestring.h
main()
{
char c,filename[20];
char yanzhengma[20];
FILE *fp1,*fp2;
printf("请输入待解密文件名:\n");
scanf("%s",filename);
printf("请输入验证码:\n");
scanf("%s",yanzhengma);
if(strcmp(yanzhengma,"shan")==0)
{
fp1=fopen(filename,"r");
fp2=fopen("yuanwen.txt","w");
do
{
c=fgetc(fp1);
if(c=32c=126)
{
c=126-c;
c=32+c;
}
if(c!=-1)
fprintf(fp2,"%c",c);
}
while(c!=-1);
}
else
{
printf("验证码错误!请重新输入:\n");
scanf("%s",filename);
}
}