当前位置:网站首页>MFC on the conversion and display of long string unsigned char and CString
MFC on the conversion and display of long string unsigned char and CString
2022-07-06 06:18:00 【Laobai 436196571】
Today I met about MD5 Generate registration code input and display problems , The solution process is recorded below
1、 Dialog window input CString turn unsigned char Array
CString regstr;
unsigned char reg_code[20]="1234";// Test array
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);// Dialog input
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);// Test whether direct input is the same as dialog input
delete[] c_user_data;
delete[] uc_user_data;
c_user_data=NULL;
uc_user_data=NULL;
2、 The dialog window displays MD5 code ,unsigned char Array rotation CString, The dialog box shows the output
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、 test (MD5 Registration code after adding salt )
边栏推荐
- [wechat applet] build a development tool environment
- 异常检测方法总结
- Réflexions sur la sécurité des données (réimpression)
- Database isolation level
- Full link voltage measurement: building three models
- Cannot create PoolableConnectionFactory (Could not create connection to database server. 错误
- Leaflet map
- LeetCode 729. 我的日程安排表 I
- Aike AI frontier promotion (2.13)
- 浅谈专项测试之弱网络测试
猜你喜欢

LeetCode 732. 我的日程安排表 III

oscp raven2靶机渗透过程

[no app push general test plan

全链路压测:构建三大模型

How to extract login cookies when JMeter performs interface testing

把el-tree选中的数组转换为数组对象

B - The Suspects
![[postman] collections configuration running process](/img/09/bcd9fd6379fa724671ffd09278442e.png)
[postman] collections configuration running process

技术分享 | 常见接口协议解析

Expose the serial fraudster Liu Qing in the currency circle, and default hundreds of millions of Cheng Laolai
随机推荐
Significance of unit testing
Cannot create PoolableConnectionFactory (Could not create connection to database server. 错误
Isam2 and incrementalfixedlagsmooth instructions in gtsam
GTSAM中李群的運用
[C language] qsort function
Réflexions sur la sécurité des données (réimpression)
Expose the serial fraudster Liu Qing in the currency circle, and default hundreds of millions of Cheng Laolai
Seven imperceptible truths in software testing
通过修改style设置打印页样式
Digital triangle model acwing 1015 Picking flowers
测试周期被压缩?教你9个方法去应对
Manage configuration using Nacos
selenium源码通读·9 |DesiredCapabilities类分析
模拟卷Leetcode【普通】1219. 黄金矿工
Win10 cannot operate (delete, cut) files
使用Nacos管理配置
Buuctf-[gxyctf2019] no dolls (xiaoyute detailed explanation)
An article was uncovered to test the truth of outsourcing companies
联合索引的左匹配原则
模拟卷Leetcode【普通】1296. 划分数组为连续数字的集合