-
大小: 718KB文件類型: .zip金幣: 2下載: 1 次發(fā)布日期: 2024-02-16
- 語言: C/C++
- 標(biāo)簽: MFC??仿射密碼??Affinecipher??課程設(shè)計(jì)??VisualC++??
資源簡介
題目:課程設(shè)計(jì)
環(huán)境:Visual C++ 6.0
仿射密碼是由加法密碼和乘法密碼結(jié)合就構(gòu)成。
仿射密碼的加密和解密算法是:
C= Ek(m)=(k1m+k2) mod n
M= Dk(c)=k3(c- k2) mod n(其中(k3 ×k1)mod26 = 1)
仿射密碼具有可逆性的條件是gcd(k1, n)=1。當(dāng)k1=1時(shí),仿射密碼變?yōu)榧臃艽a,當(dāng)k2=0時(shí),仿射密碼變?yōu)槌朔艽a。
仿射密碼中的密鑰空間的大小為nφ(n),當(dāng)n為26字母,φ(n)=12,因此仿射密碼的密鑰空間為12×26 = 312。
此軟件實(shí)現(xiàn)了仿射密碼的加密和解密算法,通過網(wǎng)絡(luò)傳遞加解密的數(shù)據(jù)。
如有問題請聯(lián)系 QQ:369946814 HeiSir

代碼片段和文件信息
//?Dlg_Decode.cpp?:?implementation?file
//
#include?“stdafx.h“
#include?“gh0st.h“
#include?“Dlg_Decode.h“
#include?
#pragma?comment(lib“ws2_32.lib“)
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//?CDlg_Decode?dialog
CDlg_Decode::CDlg_Decode(CWnd*?pParent?/*=NULL*/)
:?CDialog(CDlg_Decode::IDD?pParent)
{
//{{AFX_DATA_INIT(CDlg_Decode)
//?NOTE:?the?ClassWizard?will?add?member?initialization?here
//}}AFX_DATA_INIT
}
void?CDlg_Decode::DoDataExchange(CDataExchange*?pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlg_Decode)
DDX_Control(pDX?IDC_SPIN_K2?m_Spin_K2);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlg_Decode?CDialog)
//{{AFX_MSG_MAP(CDlg_Decode)
ON_WM_SIZE()
ON_EN_CHANGE(IDC_EDIT_K2?onchangeEditK2)
ON_BN_CLICKED(IDC_BUTTON_DECODE?OnButtonDecode)
ON_BN_CLICKED(IDC_BUTTON_RECV?OnButtonRecv)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//?CDlg_Decode?message?handlers
BOOL?CDlg_Decode::OnInitDialog()?
{
CDialog::OnInitDialog();
WSADATA?wsaData;
WSAStartup(MAKEWORD(22)&wsaData);
//?TODO:?Add?extra?initialization?here
m_Spin_K2.SetBuddy(GetDlgItem(IDC_EDIT_K2));
m_Spin_K2.SetRange(026);
m_Spin_K2.SetPos(0);
SetDlgItemInt(IDC_EDIT_K2m_Spin_K2.GetPos());
((CComboBox?*)GetDlgItem(IDC_COMBO_K1))->SetCurSel(0);
CFont?font_m_edit;
font_m_edit.CreateFont(18???????????//?以邏輯單位方式指定字體的高度
16???????????????????????????????//?以邏輯單位方式指定字體中字符的平均寬度
0???????????????????????????????//?指定偏離垂線和X軸在顯示面上的夾角(單位:0.1度)
0???????????????????????????????//?指定符串基線和X軸之間的夾角(單位:0.1度)
FW_NORMAL???????????????????????//?指定字體鎊數(shù)
FALSE???????????????????????????//?是不是斜體
FALSE???????????????????????????//?加不加下劃線
0???????????????????????????????//?指定是否是字體字符突出
ANSI_CHARSET????????????????????//?指定字體的字符集
OUT_DEFAULT_PRECIS??????????????//?指定所需的輸出精度
CLIP_DEFAULT_PRECIS?????????????//?指定所需的剪貼精度
DEFAULT_QUALITY?????????????????//?指示字體的輸出質(zhì)量
DEFAULT_PITCH?|?FF_SWISS????????//?指定字體的間距和家族
_T(“宋體“)???????????????????????//?指定字體字樣的名稱
);
GetDlgItem(IDC_EDIT_TEXT)->SetFont(&font_m_edit);
GetDlgItem(IDC_EDIT_ENCRYPT)->SetFont(&font_m_edit);
memset(CurPath01024);
GetModuleFileName(NULLCurPath1024);
for(int?i?=?strlen(CurPath);?i>=0;?i--)
{
if(CurPath[i]==‘\\‘)
{
CurPath[i]?=?‘\0‘;
break;
}
}
PahtConfig=CurPath;
PahtConfig+=“\\config.ini“;
CString?PortStr;
Port=GetPrivateProfileInt(“Listen““port“8888PahtConfig);
PortStr.Format(“%d“Port);
WritePrivateProfileString(“Listen““port“PortStrPahtConfig);
AfxBeginThread(ThreadRecvEncryptthis);
return?TRUE;??//?return?TRUE?unless?you?set?the?focus?to?a?control
//?EXCEPTION:?OCX?Property?Pages?should?return?FALSE
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-08-27?14:39??Bin\
?????文件??????????56??2013-08-27?14:39??Bin\config.ini
?????文件??????520192??2013-08-27?14:38??Bin\仿射加解密系統(tǒng).exe
?????目錄???????????0??2013-08-27?14:39??gh0st\
?????文件????????6811??2013-08-27?14:24??gh0st\Dlg_Decode.cpp
?????文件????????1459??2013-08-27?14:21??gh0st\Dlg_Decode.h
?????文件????????8038??2013-08-27?14:24??gh0st\Dlg_Encrypt.cpp
?????文件????????1443??2013-08-27?14:23??gh0st\Dlg_Encrypt.h
?????文件????????6414??2013-08-27?09:49??gh0st\DllFromMem.cpp
?????文件?????????996??2010-10-12?13:32??gh0st\DllFromMem.h
?????文件??????340964??2013-08-27?14:38??gh0st\gh0st.aps
?????文件????????2465??2013-08-27?14:38??gh0st\gh0st.clw
?????文件????????3227??2013-08-27?11:49??gh0st\gh0st.cpp
?????文件????????4700??2013-08-27?14:38??gh0st\gh0st.dsp
?????文件?????????535??2013-08-26?20:16??gh0st\gh0st.dsw
?????文件????????1313??2013-08-26?20:16??gh0st\gh0st.h
?????文件????????8202??2013-08-27?14:38??gh0st\gh0st.rc
?????文件????????5773??2013-08-27?09:48??gh0st\gh0stDlg.cpp
?????文件????????1549??2013-08-26?22:03??gh0st\gh0stDlg.h
?????目錄???????????0??2013-08-27?14:31??gh0st\res\
?????文件????????1461??2013-08-27?11:52??gh0st\resource.h
?????文件???????13192??2013-08-27?10:24??gh0st\res\black.she
?????文件?????????397??2013-08-26?20:16??gh0st\res\gh0st.rc2
?????文件??????204862??2013-08-27?11:52??gh0st\res\perl.exe_0_0.ico
?????文件???????86528??2013-08-26?23:08??gh0st\res\SkinH.dll
?????文件?????????207??2013-08-26?20:16??gh0st\StdAfx.cpp
?????文件????????1054??2013-08-26?20:16??gh0st\StdAfx.h
評論
共有 條評論