基于VCCeasar加密和解密技术
一、Clear原理
对每一明文字母P,代换成密文字母C:
C=E(P)=(P+3) mod (26)
移位就可以是任意整数K,这样就得到了一般的Ceasar算法:
C=E(P)=(P+K) mod (26)
这里K的取值范围从1到25。解密算法是:
P=D(C)=(C-K)mod (26)
二、开发平台及语言
1、开发平台:Microsoft Visual Studio c++ 6.0
2.语言: c++
三、应用程序界面设计及变量的连接和方法的名称
对象
ID
Caption
连接变量或方法
成组框
IDC_STATIC
产生密钥
编辑框
IDC_NUMBER_EDIT
m_NumberEdit/CEdit
编辑框
IDC_RESOURCE_EDIT
m_ResourceEdit/CEdit
OnChangeResourceEdit()
编辑框
IDC_ENCRYPT_EDIT
m_EncryptEdit/CEdit
编辑框
IDC_OPEN_EDIT
m_OpenEdit/CEdit
编辑框
IDC_LINE
m_Line/CEdit
编辑框
IDC_CHAR
m_Char/CEdit
编辑框
IDC_KEY_EDIT
m_KeyEdit/CEdit
命令按钮
IDC_CLEARNUM_BUTTON
重置
OnClearnumButton()
命令按钮
IDC_HIDEKEY_BUTTON
隐藏密钥
OnHidekeyButton()
命令按钮
IDC_SHOWKEY_BUTTON
显示密钥
OnShowkeyButton()
命令按钮
IDC_CLEARKEY_BUTTON
重置
OnClearkeyButton()
命令按钮
IDC_HIDETEXT_BUTTON
隐藏密文
OnHidetextButton()
命令按钮
IDC_SHOWTEXT_BUTTON
显示密文
OnShowtextButton()
命令按钮
IDC_OK_BUTTON
确定
OnOkButton()
命令按钮
IDC_CLEAR_BUTTON
Clear
OnClearButton()
命令按钮
IDC_EXIT_BUTTON
Exit
OnExitButton()
命令按钮
IDC_ENCRYPT_BUTTON
加密
OnEncryptButton()
命令按钮
IDC_OPEN_BUTTON
解密
OnOpenButton()
编辑框
IDC_FORCE_OPEN_EDIT
m_ForceOpenEdit/CEdit
编辑框
IDC_GETENCRYPT_EDIT
m_GetEncryptEdit/CEdit
菜单
ID_ENCRYPT_MENU
加密
OnEncryptMenu()
菜单
ID_OPEN_MENU
解密
OnOpenMenu()
菜单
ID_CLEAR_MENU
清除
OnClearMenu()
菜单
ID_EXIT_MENU
退出
OnExitMenu()
菜单
ID_ABOUT_MENU
关于
OnAboutMenu()
四、CeasarDlg.h声明
// CeasarDlg.h : header file
#if !defined(AFX_CEASARDLG_H__E2ECB937_D748_475D_BDA2_6D8728998EFC__INCLUDED_)
#define AFX_CEASARDLG_H__E2ECB937_D748_475D_BDA2_6D8728998EFC__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
Const char lowerArray[26]={'a','b','c','d','e','f','g','h','i','j','k','l',
'm','n','o','p','q','r','s','t','u','v','w','x','y','z'};
const char upperArray[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','
Q','R','S','T','U','V','W','X','Y','Z'};
/
// CCeasarDlg dialog
class CCeasarDlg : public CDialog
{
// Construction
public:
CCeasarDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CCeasarDlg)
enum { IDD = IDD_CEASAR_DIALOG };
CEdit m_GetEncryptEdit;
CEdit m_GetEnryptEdit;
CEdit m_ForceOpenEdit;
CEdit m_NumberEdit;
CEdit m_KeyEdit;
CEdit m_EncryptEdit;
CEdit m_ResourceEdit;
CEdit m_OpenEdit;
CEdit m_Line;
CEdit m_Char;
CEdit m_keyEdit;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCeasarDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CCeasarDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnClearkeyButton();
afx_msg void OnHidekeyButton();
afx_msg void OnShowkeyButton();
afx_msg void OnChangeResourceEdit();
afx_msg void OnClearButton();
afx_msg void OnExitButton();
afx_msg void OnHidetextButton();
afx_msg void OnShowtextButton();
afx_msg void OnEncryptButton();
afx_msg void OnOpenButton();
afx_msg void OnOkButton();
afx_msg void OnClearnumButton();
afx_msg void OnEncryptMenu();
afx_msg void OnOpenMenu();
afx_msg void OnExitMenu();
afx_msg void OnClearMenu();
afx_msg void OnAboutMenu();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CEASARDLG_H__E2ECB937_D748_475D_BDA2_6D8728998EFC__INCLUDED_)
五、映射消息的应用程序代码
1、void CCeasarDlg::OnClearkeyButton()
{
// TODO: Add your control notification handler code here
m_KeyEdit.SetSel(0,-1);
m_KeyEdit.ReplaceSel("");
}
2、void CCeasarDlg::OnHidekeyButton()
{
// TODO: Add your control notification handler code here
m_KeyEdit.ShowWindow(SW_HIDE);
}
3、void CCeasarDlg::OnShowkeyButton()
{
// TODO: Add your control notification handler code here
m_KeyEdit.ShowWindow(SW_SHOW);
}
4、void CCeasarDlg::OnChangeResourceEdit()
{
// TODO: Add your control notification handler code here
CString METext;
char Count[10];
int nCharNum,nLineNum;
m_ResourceEdit.GetWindowText(METext);
nCharNum=METext.GetLength();
nLineNum=m_ResourceEdit.GetLineCount();
itoa(nCharNum,Count,10);
m_Char.SetWindowText(Count);
itoa(nLineNum,Count,10);
m_Line.SetWindowText(Count);
}
5、void CCeasarDlg::OnClearButton()
{
// TODO: Add your control notification handler code here
m_ResourceEdit.SetSel(0,-1);
m_ResourceEdit.ReplaceSel("");
m_EncryptEdit.SetSel(0,-1);
m_EncryptEdit.ReplaceSel("");
m_OpenEdit.SetSel(0,-1);
m_OpenEdit.ReplaceSel("");
UpdateData(FALSE);
}
6、void CCeasarDlg::OnExitButton()
{
// TODO: Add your control notification handler code here
OnOK();
}
7、void CCeasarDlg::OnHidetextButton()
{
// TODO: Add your control notification handler code here
m_EncryptEdit.ShowWindow(SW_HIDE);
}
8、void CCeasarDlg::OnShowtextButton()
{
// TODO: Add your control notification handler code here
m_EncryptEdit.ShowWindow(SW_SHOW);
}
9、void CCeasarDlg::OnEncryptButton()
{
// TODO: Add your control notification handler code here
char sArray[10];
int nCount;
int nKey;
m_Char.GetWindowText(sArray,10);
nCount=atoi(sArray);
m_KeyEdit.GetWindowText(sArray,10);
nKey=atoi(sArray);
char sResourceText[300];
char sEncryptText[300];
char *pResourceText=sResourceText;
char *pEncryptText=sEncryptText;
m_ResourceEdit.GetWindowText(sResourceText,300);
int nTemp1,nTemp2,i,j;
for(i=0;i<nCount;i++)
{
if((*pResourceText>='A'&&*pResourceText<='Z')||(*pResourceText>='a'&&*pResourceText<='z'))
{
if(*pResourceText>='A'&&*pResourceText<='Z')
{
for(j=0;j<26;j++)
if(upperArray[j]==*pResourceText)
{
nTemp1=j;
break;
}
nTemp2=(nTemp1+nKey%26)%26;
*pEncryptText=upperArray[nTemp2];
}
else
{
for(j=0;j<26;j++)
if(lowerArray[j]==*pResourceText)
{
nTemp1=j;
break;
}
nTemp2=(nTemp1+nKey%26)%26;
*pEncryptText=lowerArray[nTemp2];
}
}
else
*pEncryptText=*pResourceText;
pResourceText++;
pEncryptText++;
}
*pEncryptText='\0';
m_EncryptEdit.SetWindowText(sEncryptText);
}
10、void CCeasarDlg::OnOpenButton()
{
// TODO: Add your control notification handler code here
char sArray[10];
int nCount;
int nKey;
m_Char.GetWindowText(sArray,10);
nCount=atoi(sArray);
m_KeyEdit.GetWindowText(sArray,10);
nKey=atoi(sArray);
char sOpenText[300];
char sEncryptText[300];
char *pOpenText=sOpenText;
char *pEncryptText=sEncryptText;
m_EncryptEdit.GetWindowText(sEncryptText,300);
int nTemp1,nTemp2,i,j;
for(i=0;i<nCount;i++)
{
if((*pEncryptText>='A'&&*pEncryptText<='Z')||(*pEncryptText>='a'&&*pEncryptText<='z'))
{
if(*pEncryptText>='A'&&*pEncryptText<='Z')
{
for(j=0;j<26;j++)
if(upperArray[j]==*pEncryptText)
{
nTemp1=j;
break;
}
nTemp2=(nTemp1-nKey%26+26)%26;
*pOpenText=upperArray[nTemp2];
}
else
{
for(j=0;j<26;j++)
if(lowerArray[j]==*pEncryptText)
{
nTemp1=j;
break;
}
nTemp2=(nTemp1-nKey%26+26)%26;
*pOpenText=lowerArray[nTemp2];
}
}
else
*pOpenText=*pEncryptText;
pEncryptText++;
pOpenText++;
}
*pOpenText='\0';
m_OpenEdit.SetWindowText(sOpenText);
}
11、void CCeasarDlg::OnOkButton()
{
// TODO: Add your control notification handler code here
char sArray[10];
int nCount;
int nNumber;
m_Char.GetWindowText(sArray,10);
nCount=atoi(sArray);
m_NumberEdit.GetWindowText(sArray,10);
nNumber=atoi(sArray);
char sForceOpenText[300];
char sGetEncryptText[300];
char *pForceOpenText=sForceOpenText;
char *pGetEncryptText=sGetEncryptText;
m_GetEncryptEdit.GetWindowText(sGetEncryptText,300);
int nTemp1,nTemp2,i,j;
for(i=0;i<nCount;i++)
{
if((*pGetEncryptText>='A'&&*pGetEncryptText<='Z')||(*pGetEncryptText>='a'&&*pGetEncryptText<='z'))
{
if(*pGetEncryptText>='A'&&*pGetEncryptText<='Z')
{
for(j=0;j<26;j++)
if(upperArray[j]==*pGetEncryptText)
{
nTemp1=j;
break;
}
nTemp2=(nTemp1-nNumber+26)%26;
*pForceOpenText=upperArray[nTemp2];
}
else
{
for(j=0;j<26;j++)
if(lowerArray[j]==*pGetEncryptText)
{
nTemp1=j;
break;
}
nTemp2=(nTemp1-nNumber+26)%26;
*pForceOpenText=lowerArray[nTemp2];
}
}
else
*pForceOpenText=*pGetEncryptText;
pGetEncryptText++;
pForceOpenText++;
}
*pForceOpenText='\0';
m_ForceOpenEdit.SetWindowText(sForceOpenText);
}
12、void CCeasarDlg::OnClearnumButton()
{
// TODO: Add your control notification handler code here
m_NumberEdit.SetSel(0,-1);
m_NumberEdit.ReplaceSel("");
m_ForceOpenEdit.SetSel(0,-1);
m_ForceOpenEdit.ReplaceSel("");
m_GetEncryptEdit.SetSel(0,-1);
m_GetEncryptEdit.ReplaceSel("");
}
13、void CCeasarDlg::OnEncryptMenu()
{
// TODO: Add your command handler code here
OnEncryptButton();
}
14、void CCeasarDlg::OnOpenMenu()
{
// TODO: Add your command handler code here
OnOpenButton();
}
15、void CCeasarDlg::OnExitMenu()
{
// TODO: Add your command handler code here
OnExitButton();
}
16、void CCeasarDlg::OnClearMenu()
{
// TODO: Add your command handler code here
OnClearButton();
}
17、void CCeasarDlg::OnAboutMenu()
{
// TODO: Add your command handler code here
MessageBox("This is a Clear!");
}

基于VC的Ceasar加密和解密技术相关推荐

  1. 模拟QQ软件的基于多线程的流媒体加密传输软件技术

    模拟QQ软件的基于多线程的流媒体加密传输软件技术 模拟QQ软件,基于多线程编程捕捉摄像头及麦克风实时数据,基于socket通信设计发送端.接收端两个部分的,对音频和视频进行采集.加密或加水印.传输.解 ...

  2. 加密和解密技术基础、PKI及创建私有CA

    一.数据加密和解密概述 数据加密和解密是一门历史悠久的技术,从古代就已经出现了,一直发展到当代.其中,数据加密的目的有很多,可以是为了保证本地数据存取的安全性,可以是为了保证数据流在网络传输过程中的保 ...

  3. 【转】软件狗[Dongles]的加密与解密技术

    软件狗[Dongles]的加密与解密技术 软件狗采取了各种的加密技术,目前较先进的加密技术有以下几种: AS技术:API函数调用与SHELL外壳加密结合,即使外壳被破坏,加密程序依然不能正常运行. 反 ...

  4. 【图像加密】基于Logistic混沌图像加密与解密Matlab代码

    1 简介 当今时代,科学技术发展迅猛,网络成为人们获取成为人们获取多媒体数字信息的主要渠道,数字图像作为日常交流的主要传输媒介,更是承担着信息传递的重任.保证信息在传播过程中的安全性和完整性便成了目前 ...

  5. 加密与解密技术原理(密码学)

    加密与解密原理 1. 加密技术发展 加密是利用数学方法将明文转化为密文,从而达到保护数据的目的. 通过加密可保证数据的机密性.完整性.鉴别性.不可否认性. 机密性:通过数据加密实现.只允许特定用户访问 ...

  6. 基于RHEL7进行grub加密和解密

    上一篇文档教了当我们忘记了RHEL7登录密码后如何通过紧急救援模式去修改密码,今天这篇文档将教你如何对登录密码进行grub加密和解密. 首先,我们登录一台服务器,使用grub加密命令生成一条繁琐的密码 ...

  7. 黑客学习-密码学:基于openssl的算法加密和解密

    在Linux系统中自带openssl工具,加密和解密,可以在Linux上进行.利 openssl工具,用DES.3DES.IDEA.AES等对称算法对文件加密解密,和用RSA非对称算法对文件加密解密. ...

  8. 芯片加密与解密技术方法

    目录: 一.简介 二.硅芯片安全措施的演变 三.总结 ------------------------------------------------------------------------- ...

  9. Java加密与解密的艺术~AES-GCM-NoPadding实现

    来源:Java AES加密和解密_一名可爱的技术搬运工-CSDN博客 高级加密标准 (AES,Rijndael)是一种分组密码加密和解密算法,是全球使用最广泛的加密算法. AES使用128.192或2 ...

  10. 如何使用 Visual C# 加密和解密文件

    本文引入的命名空间: System.IO System.Security System.Security.Cryptography 本文介绍如何使用 Microsoft .NET Framework ...

最新文章

  1. Linux命令行与命令
  2. 缩小数据文件尺寸报ORA-03297的处理办法
  3. Exchange server 2003迁移到2010之升级默认地址簿及地址策略
  4. java高并发(十)线程不安全类与写法
  5. json-schema 可视化编辑器发布了
  6. SQL零基础学习笔记(一)
  7. Analyzer报表结果行
  8. input中的name,value以及label中的for
  9. 12c r2单实例 静默安装软件
  10. cakephp helper ajax,在JS Helper CakePHP中手动触发事件
  11. Perceptron实践
  12. 算法笔记(23)网格搜索及Python代码实现
  13. ubuntu笔记本gpu温度太高解决办法
  14. 关于用友财务总账的数据库关系
  15. 分享几个纯净版Windows系统下载网站
  16. 【BP回归预测】基于matlab鲸鱼算法优化BP神经网络回归预测(多输入单输出)【含Matlab源码 1554期】
  17. 如何在Microsoft Word里面插入图片作为背景?
  18. 用python搭建微商城_怎么搭建微商城?用什么系统好?
  19. 团队管理之亮剑精神(转)
  20. 微信小程序 - 婚礼邀请函

热门文章

  1. 转载:ecCodes 学习 利用ecCodes Python API对GRIB文件进行读写
  2. C语言,最新猴子摘桃(递归方法)
  3. uniapp 微信小程序 腾讯位置服务路线规划插件的使用
  4. Arduino UNO驱动DS1307数字实时时钟RTC
  5. TIdTCPClient 详解
  6. Rush Hour Puzzle
  7. 计算机英语解读,解释计算机Windows的学习英语
  8. phalapi做登录检测_PhalApi框架使用笔记
  9. Windows 开启护眼模式 | Windows护眼软件
  10. taylor+swift纽约公寓_Taylor Swift $1,800 万美元的纽约豪宅到底豪在哪里?