我正计划创建一个加密程序。基本上将正常的“abcdefghijklmnopqrstuvwxyz”中的任何内容交换为“thequickbrownfxjmpsvlazydg”。
例如,如果我要键入“abc”,结果将是“the”。
#include <stdio.h>
#include <string.h>
void encrypt(char *text, char *map);
void decrypt(char *text, char *map);
int main()
{
char a[] = {'a','b','c','d','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char b[] = {'t','h','e','q','u','i','c','k','b','r','o','w','n','f','x','j','m','p','s','v','l','a','z','y','d','g'};
char *textptr;
char *mapptr;
textptr = a;
mapptr = b;
encrypt(textptr, mapptr);
return 0;
}
void encrypt(char *text, char *map)
{
char string[100];
int len;
int x = 0, y = 0, l = 1;
printf("Please enter the string: ");
scanf("%s", string);
len = strlen(string);
for (x = 0; x < len; x++)
{
for (y = 0; y < 26; y++)
{
if(text[x] == map[y])
text[x] = map[y];
}
}
printf("The Ciphertext is: %s", string);
}
并且输出与输入的纯文本相同..你们能帮我吗?