当前位置:网站首页>MFC关于长字符串unsigned char与CString转换及显示问题
MFC关于长字符串unsigned char与CString转换及显示问题
2022-07-06 06:09:00 【老白436196571】
今天遇到关于MD5生成注册码输入及显示问题,解决过程记录以下
1、对话框窗口输入CString转unsigned char数组
CString regstr;
unsigned char reg_code[20]="1234";//测试数组
unsigned char reg_code_md5[20];
union TRAN_DATA
{
char c_data;
unsigned char uc_data;
};
TRAN_DATA tran_data;
GetDlgItemText(IDC_EDIT_writereg,regstr);//对话框输入
DWORD dwNum = WideCharToMultiByte(CP_OEMCP,NULL,regstr.GetBuffer(),-1,NULL,0,NULL,FALSE);
char *c_user_data = new char[dwNum];
unsigned char *uc_user_data = new unsigned char[dwNum];
memset( c_user_data,0 ,dwNum);
WideCharToMultiByte (CP_OEMCP,NULL,regstr.GetBuffer(),-1,c_user_data,dwNum,NULL,FALSE);
for(int i=0;i<dwNum;i++)
{
tran_data.c_data=c_user_data[i];
uc_user_data[i]=tran_data.uc_data;
}
Write_Regcode(card_no[0],uc_user_data,reg_code_md5);
//Write_Regcode(card_no[0],reg_code,reg_code_md5);//测试直接输入与对话框输入是否相同
delete[] c_user_data;
delete[] uc_user_data;
c_user_data=NULL;
uc_user_data=NULL;
2、对话框窗口显示MD5码,unsigned char数组转CString,对话框显示输出
CString str;
CString str0;
// for ( int i = 0; i < sizeof (reg_code_md5) / sizeof (reg_code_md5[0]); i++)
for ( int i = 0; i < 16; i++)
{
str0.Format(_T("%02X"),reg_code_md5[i]);
str +=str0;
}
SetDlgItemText(IDC_EDIT_readreg,str);
3、测试(MD5加盐后注册码)
边栏推荐
猜你喜欢

G - Supermarket

JWT-JSON WEB TOKEN

Significance of unit testing

Usage of test macro of GTEST

Understanding of processes and threads

How to use the container reflection method encapsulated by thinkphp5.1 in business code

Summary of anomaly detection methods

把el-tree选中的数组转换为数组对象
![Buuctf-[bjdctf2020]zjctf, but so (xiaoyute detailed explanation)](/img/c9/56fba6054c91f090de31463a8b4705.jpg)
Buuctf-[bjdctf2020]zjctf, but so (xiaoyute detailed explanation)

功能安全之故障(fault),错误(error),失效(failure)
随机推荐
RestTemplate、Feign实现Token传递
G - Supermarket
二维码的前世今生 与 六大测试点梳理
Linux regularly backs up MySQL database
Luogu p1460 [usaco2.1] healthy Holstein cows
【微信小程序】搭建开发工具环境
[postman] test script writing and assertion details
Web界面元素的测试
Eigen稀疏矩阵操作
GTSAM中李群的运用
Sqlmap tutorial (III) practical skills II
E - 食物链
Nodejs realizes the third-party login of Weibo
Detailed explanation of P problem, NP problem, NPC problem and NP hard problem
联合索引的左匹配原则
Interface test: what are the components of the URL in fiddler
[postman] the monitors monitoring API can run periodically
【Postman】动态变量(也称Mock函数)
【Postman】Monitors 监测API可定时周期运行
Testing and debugging of multithreaded applications