| 
				 // 对文件明文加密函数,  in为明文流,out是辅助文件流,key为加密密钥(8个16位) 
void cipher_file(FILE *in,FILE *out,word16 *key) 
{ 
   word16 input[4],output[4]; 
   IDEAkey Z;  //IDEAkey 是word16型的数组,有52个元素 
   int x,y; 
   int count=0; 
   long length; 
   int temp; 
  
   en_key_idea(key,Z);  // 生成52个子密钥 
   end_of_file=0; 
  
   length=filelength(fileno(in));  // 取得明文文件长度 
   fwrite(&length,sizeof(long),1,out); // 写入文件长度(4个字节,32位)到out文件流 
  
   while (!end_of_file)  //文件没有结束 
   { 
      x=0; 
                   /*    核心代码    */ 
      while (x<4)  //读出64位明文,分4次读出 
      { 
     input[x]=((word16)(read_char_from_file(in)<<8)); //一次读出8位明文 ,并左移8位 成为16位子分组的高8位 
     if (!end_of_file) 
     { 
        temp=read_char_from_file(in);  // 读出8位明文 
  
        if (temp<0) temp+=256;   
        input[x]=input[x]|temp;  //  子分组的低8位 
        x++; 
     } 
     if (end_of_file)  //最后一次如果明文不足64位, 补0 
     { 
        while (x<4) input[x++]=0; 
        break;      }			
				 |