源代码下载地址:
      
关键代码如下 
 
- void CRijndView::OnUncryption() 
 
 - {
 
 -         // TODO: Add your control notification handler code here
 
 -                 k_bit=(unsigned char*)m_miyao.GetBuffer(8);
 
 -         m_miyao.ReleaseBuffer();                                                //密钥的获取
 
 -         unsigned char *m_bit;
 
 -         m_bit=new unsigned char [length];
 
 -         BeginWaitCursor();
 
 -         {
 
 -         rij.set_key(k_bit,256);
 
 -                 for(int j=0;j<N;j++)
 
 -                 {
 
 -                         rij.decrypt(var,m_bit);
 
 -                         m_bit+=16;
 
 -                         var+=16;
 
 -                 }
 
 -                 m_bit=m_bit-16*N;
 
 -                 var=var-16*N;
 
 -         }
 
 -         EndWaitCursor();
 
  
-                 char szFilter[] = "all Files(*.*)|*.*||";
 
 -                 CFileDialog FileDlg( FALSE, NULL, NULL, OFN_HIDEREADONLY, szFilter );
 
 -                 FileDlg.m_ofn.lpstrTitle="解密文件存为";
 
 -                 if( FileDlg.DoModal() == IDOK ){
 
 -                         BeginWaitCursor();
 
 -                         CString PathName = FileDlg.GetPathName();
 
 -                         PathName=PathName+name;
 
  
-                         CFile f;
 
 -                     f.Open(PathName,
 
 -                         CFile::modeCreate|CFile::modeWrite);
 
 -                         f.Write(m_bit,length);
 
 -                         f.Close();
 
 -                         CString string;
 
 -                         string="notepad"+PathName;
 
 -                         WinExec(string,SW_SHOW);
 
  
-                         m_jiami="解密结束!";
 
 -                         MessageBox(m_jiami);
 
 -                         EndWaitCursor();
 
 -                 }
 
  
-                         delete m_bit;
 
 -                         UpdateData(false);
 
 -                         Invalidate(true);
 
 -         
 
 - }
 
  
- void CRijndView::OnEncryptionSelect() 
 
 - {
 
 -         // TODO: Add your control notification handler code here
 
 -         char szFilter[] = "all Files(*.*)|*.*||";
 
 -         CFileDialog FileDlg( TRUE, NULL, NULL, OFN_HIDEREADONLY, szFilter );
 
  
-         if( FileDlg.DoModal() == IDOK )
 
 -         {
 
 -                 BeginWaitCursor();
 
 -                 CString PathName = FileDlg.GetPathName();
 
 -                 CString filename=FileDlg.GetFileName();
 
 -                 CString first=FileDlg.GetFileTitle();
 
 -                 name=filename.Right(filename.GetLength()-first.GetLength());
 
 -                 {
 
 -                         CFile f2;
 
 -                         if(f2.Open(PathName,CFile::modeRead|CFile::typeBinary  )==FALSE)
 
 -                         return;
 
 -                         length=f2.GetLength();
 
 -                         
 
 -                         N=length/16;
 
 -                         if(length%16==0)
 
 -                         {
 
 -                                 N=N;
 
 -                         }
 
 -                         else
 
 -                         {
 
 -                                 length=length+16-length%16;
 
 -                                 N=N+1;
 
 -                         }
 
  
-                         var=new unsigned char [length];
 
  
-                         f2.Read(var,f2.GetLength());
 
  
-                         if(f2.GetLength()%16!=0)
 
 -                         {
 
 -                                 for(i=0;i<(int)(16-f2.GetLength()%16);i++)
 
 -                                 {
 
 -                                         var[length-16+f2.GetLength()%16+i]=' ';
 
 -                                 }
 
 -                         }
 
 -                         
 
 -                         f2.Close();
 
 -                         Invalidate(true);
 
  
-                 }
 
 -                 EndWaitCursor();
 
 -         }
 
 - }
 
  
- void CRijndView::OnUncryptionSelect() 
 
 - {
 
 -         // TODO: Add your control notification handler code here
 
 -                 char szFilter[] = "all Files(*.*)|*.*||";
 
 -         CFileDialog FileDlg( TRUE, NULL, NULL, OFN_HIDEREADONLY, szFilter );
 
  
-         if( FileDlg.DoModal() == IDOK )
 
 -         {
 
 -                 BeginWaitCursor();
 
 -                 CString PathName = FileDlg.GetPathName();
 
 -                 CString filename=FileDlg.GetFileName();
 
 -                 CString first=FileDlg.GetFileTitle();
 
 -                 name=filename.Right(filename.GetLength()-first.GetLength());
 
  
-                 {
 
 -                         CFile f2;
 
 -                         if(f2.Open(PathName,CFile::modeRead|CFile::typeBinary  )==FALSE)
 
 -                         return;
 
 -                         length=f2.GetLength();
 
  
-                         var=new unsigned char [length];
 
 -                         N=length/16;
 
 -                         f2.Read(var,f2.GetLength());                        
 
 -                         f2.Close();                
 
 -                         Invalidate(true);
 
 -                 }
 
 -                 EndWaitCursor();
 
 -         }
 
 - }
 
 
  复制代码 
 
 
 |