承接国内外服务器租用托管、定制开发、网站代运营、网站seo优化托管接单、网站代更新,新老站点皆可!!咨询QQ:3787320601

怎么将:mfc怎么将文本数据加密

管理员 2023-03-30 09:54:01 互联网圈 45 ℃ 0 评论 1528字 收藏

mfc怎样将文本数据加密

mfc如何将文本数据加密

使用mfc对文本数据进行加密的方法

mfc代码以下:

#include "stdafx.h"

#include "EncodeAndDecode.h"

#include "afxdialogex.h"

EncodeAndDecode::EncodeAndDecode()

{

}

EncodeAndDecode::~EncodeAndDecode()

{

}

void EncodeAndDecode::EncodeFile()

{

//读取配置文件

CString fPath("./data.txt");

CFile openFile;

bool bFile = openFile.Open(fPath, CFile::modeRead);

//同根目录下判断是否是打开

if (!bFile)

{

MessageBox(NULL,_T("系统文件丢失请联系管理员"), _T("毛病") ,MB_ICONINFORMATION);

exit(0);

}

DWORD openSize = (DWORD)openFile.GetLength();

char* buf = new char[openSize + 1];

memset(buf, 0, sizeof(char) * (openSize + 1));

openFile.Read(buf, openSize);

openFile.Close();

//加密算法

for (unsigned int i = 0; i < openSize; i++)

{

buf[i] = 255 - buf[i];

}

//写入加密文件

CString wPath("./moon.xie");

CFile writeFile;

writeFile.Open(wPath, CFile::modeWrite | CFile::modeCreate);

writeFile.Write(buf, openSize);

writeFile.Close();

//MessageBox(NULL, _T("已加密"), _T("成功"), MB_ICONINFORMATION);

}

文章来源:丸子建站

文章标题:怎么将:mfc怎么将文本数据加密

https://www.wanzijz.com/view/5495.html

TAG: 数据加密 mfc

相关文章

Related articles

X

截屏,微信识别二维码

微信号:weimawl

(点击微信号复制,添加好友)

打开微信