⑴ 如何用c语言写仿射密码和维吉尼亚密码只用C语言函数完成代码,谢谢。
void *(* func) (void *){}
一般写函数的时候不会在函数名前面加*再括号括起来的。如果是函数指针
那么就是返回void*类型。如果真的是函数定义的话,
感觉不会这么写的,还不如写void ** func (void *) 这种名字呢。
⑵ 用C语言破译Vigenere Cipher,程序有点问题求指教!
j 输出几个数字
⑶ 写一个维吉尼亚加密和解码的C语言程序,具体要求如下。不要用GOTO, 不要有MAGIC NUMBER。
#include <stdio.h>
#define MINCHAR 32
#define CHARSUM 94
int encode(char* key, char* source, char* dest);
int decode(char* key, char* source, char* dest);
char table[CHARSUM][CHARSUM];
int main()
{
int i, j;
char key[256];
char source[256];
char destination[256];
int operation;
FILE *fp;
/* Initial the Vigenere table */
for(i = 0; i < CHARSUM; i++)
for(j = 0; j < CHARSUM; j++)
table[i][j] = MINCHAR + (i + j) % CHARSUM;
printf("please choose one operation code: ");
printf("1. Encode; 2. Decode; Others. Exit. ");
scanf("%d", &operation);
fflush(stdin);
switch (operation)
{
case 1:
printf("please input the key code: ");
gets(key);
fflush(stdin);
printf("please input the source code you want to encode: ");
gets(source);
fflush(stdin);
encode(key, source, destination);
printf("after encode is: ");
printf("%s ", destination);
fp=fopen("key.txt", "w");
fprintf(fp, "%s", key);
fclose(fp);
fp=fopen("source.txt", "w");
fprintf(fp, "%s", source);
fclose(fp);
fp=fopen("destination.txt", "w");
fprintf( fp, "%s",destination);
fclose(fp);
break;
case 2:
printf("please input the key code: ");
gets(key);
fflush(stdin);
printf("please input the source code you want to decode: ");
gets(source);
fflush(stdin);
decode(key, source, destination);
printf("after decode is: ");
printf("%s ", destination);
fp=fopen("key.txt", "w");
fprintf(fp, "%s", key);
fclose(fp);
fp=fopen("source.txt", "w");
fprintf(fp, "%s", source);
fclose(fp);
fp=fopen("destination.txt", "w");
fprintf(fp, "%s", destination);
fclose(fp);
break;
default:
return 0;
}
return 0;
}
int encode(char* key, char* source, char* dest)
{
char* tempSource = source;
char* tempKey = key;
char* tempDest = dest;
do
{
*tempDest = table[(*tempKey) - MINCHAR][(*tempSource) - MINCHAR];
tempDest++;
if (!(*(++tempKey)))
tempKey = key;
} while(*tempSource++);
dest[strlen(source)] = '