c语言简单加密字母大小写(c语言加密字符串)

2023-02-18 20:39:13 密码用途 思思

c语言对大写英文字母加密

#include stdio.h

#include string.h

int main()

{

char passwd[100],encrypted[100];

int i,j,k,t,move;

while(1)

{

printf("Enter message to be encrypted:");

gets(passwd);

move=3;

for(i=0; istrlen(passwd); i++)

{

if(passwd[i] = 'A' passwd[i] = 'Z')

{

passwd[i] = ((passwd[i]-'A')+move)%26+'A';

} else if(passwd[i] = 'a' passwd[i] = 'z')

{

passwd[i] = ((passwd[i]-'a')+move)%26+'a';

}

}

printf("%s",passwd);

printf("\n");

}

return 0;

}

这道题实际上就是C语言版的凯撒加密(字母往后面移动1-25之间的任意一位数)

C语言题编程实现对键盘输入的大写英文字母进行加密。字母

#includestdio.h

#includectype.h

int main()

{int i;

 char s[200];

 gets(s);

 for(i=0;s[i];i++)

   if(isalpha(s[i]))

   {s[i]+=3;

    if(s[i]%0x2026)s[i]-=26;

   }

 puts(s);

 return 0;

}

C语言指针:编写程序,对输入的一行小写字母进行加密处理。

void encrypt(char *s)

{

while(*s)

{

if(*s='a'*s='z')

*s=(*s+1-'a')%26+'a';

s++;

}

}

#includestdio.h

int main()

{

char s[128];

printf("请输入一个字符串:");

scanf("%s",s);

encrypt(s);

printf("加密后:%s\n",s);

return 0;

}

c语言简单加密字母大小写(c语言加密字符串) 第1张