📄 keyword.cpp
字号:
// Keyword.cpp: implementation of the CKeyword class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "030300816.h"
#include "Keyword.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CKeyword::CKeyword()
{
}
CKeyword::~CKeyword()
{
}
void CKeyword::Decipher()
{
for ( int i = 'a' ; i <= 'z' ; i ++ )
{
sub[m_key.GetAt(i-'a')] = i;
}
int length = m_cipherString.GetLength();
CString kk = _T("");
for ( i = 0 ; i < length ; i ++ )
{
char temp = m_cipherString.GetAt(i);
if (temp >= 'a' && temp <= 'z')
{
kk += sub[temp];
}
else if (temp >= 'A' && temp <= 'Z')
{
kk += ( sub[temp-'A'+'a'] - 'a' + 'A');
}
else
{
kk += temp;
}
}
m_plainString = kk;
}
void CKeyword::Encipher()
{
for ( int i = 0 ; i < 26 ; i ++ )
{
sub['a'+i] = m_key.GetAt(i);
}
int length = m_plainString.GetLength();
CString kk = _T("");
for ( i = 0 ; i < length ; i ++ )
{
char temp = m_plainString.GetAt(i);
if (temp >= 'a' && temp <= 'z')
{
kk += sub[temp];
}
else if (temp >= 'A' && temp <= 'Z')
{
kk += ( sub[temp-'A'+'a'] - 'a' + 'A');
}
else
{
kk += temp;
}
}
m_cipherString = kk;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -