#include
#include
#include
void Decryp( char str_Letter[], char str_Min[], char str_Mi[] )
{
int i = 0, j = 0;
for( ; str_Min[i] != '\0'; i++ )
{
int index = str_Min[i] - 'a';
str_Mi[j] = str_Letter[index];
j++;
}
}
void ChangTable(char str_Letter[], char str_NewLetter[] ) //将明密文对偶表转换成密明文对偶表
{
int i = 0;
int OldIndex = 0;
int NewIndex = 0;
for( ; i < 26; i++ )
{
OldIndex = i;
NewIndex = str_Letter[i] - 'a';
//OldIndex = i;
str_NewLetter[NewIndex] = OldIndex + 'a' ;
}
}
int menu()
{
int n = 1;
printf("\t\t1.加密
2.脱密
3.退出\n");
printf("请选择您的功能:");
scanf("%d",&n);
return n;
}
int main( void )
{
static char str_Min[100];
static char str_Mi[100];
static char str_Letter[26] = { 'a', 'c', 'b', 't', 'i', 'f', 'l', 'h', 'e', 'k', 'o', 'm', 'r', 'n', 'j', 'p', 's', 'g', 'q', 'd', 'u', 'v', 'w', 'z', 'y', 'x'};
char str_NewLetter[26];
int n = 1;
label:
n = menu();
getchar();
switch(n)
{
case 1:
printf("请输入明文:");
gets(str_Min);
Decryp( str_Letter, str_Min, str_Mi );
printf("密文:");
puts(str_Mi);
break;
case 2:
printf("请输入密文:");
gets(str_Min);
ChangTable( str_Letter, str_NewLetter );
Decryp( str_NewLetter, str_Min, str_Mi );
printf("脱密后的明文:");
puts(str_Mi);
break;
case 4:
exit(0);
break;
default:
printf("您的选择出错,按任意键退出程序!");
getchar();
exit(-1);
break;
}
goto label;
return 0;
}
#include
#include
void Decryp( char str_Letter[], char str_Min[], char str_Mi[] )
{
}
void ChangTable(char str_Letter[], char str_NewLetter[] )
{
}
int menu()
{
}
int main( void )
{
label:
}