1、/KEYWORD.H 头文件#ifndef _KEYWORD_H_#define _KEYWORD_H_typedef struct tagKeywordTablechar p;char c;KeywordTable;void cst_keyword_table (char *key);void prnt_keyword_table ();int keyword_encrypt (char *plain_txt, char *cipher_txt);int keyword_decrypt (char *cipher_txt, char *plain_txt);#endif/KEYWORD.C
2、源文件#include “keyword.h“#include #include #include KeywordTable keyword_table26;void cst_keyword_table (char *in_key)int i = 0, j, k;int char_count = 0, left_ch_index = 0;char ch, left_chs26 = 0, key26 = 0;int key_len;strcpy (key, in_key);key_len = strlen (key);while (1)if (keyi = )for (j = i; j 1)fo
3、r (k = j; k = a char key26 = 0;printf (“Please input your key (string): “);scanf (“%s“, key);cst_keyword_table (key);printf (“Keyword Table:n“);prnt_keyword_table ();printf (“Please input plain text: “);scanf (“%s“, plain_txt);keyword_encrypt (plain_txt, cipher_txt);printf (“Cipher is : %sn“, cipher_txt);keyword_decrypt (cipher_txt, plain_txt);printf (“After decryption, plain text is :%sn“, plain_txt);return 0;