当前位置:网站首页>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加盐后注册码)
边栏推荐
- IDEA 新UI使用
- 自定义指定路由上的Gateway过滤器工厂
- [postman] the monitors monitoring API can run periodically
- 技术分享 | 常见接口协议解析
- PAT(乙级)2022年夏季考试
- [API interface tool] Introduction to postman interface
- VINS-Mono: A Robust and Versatile Monocular Visual-Inertial State Estimator
- (中)苹果有开源,但又怎样呢?
- Eigen sparse matrix operation
- 数据库-当前读与快照读
猜你喜欢
Buuctf-[bjdctf2020]zjctf, but so (xiaoyute detailed explanation)
数学三大核心领域概述:代数
Embedded point test of app
Request forwarding and redirection
Function of activation function
F - true liars (category and search set +dp)
自定义指定路由上的Gateway过滤器工厂
误差的基本知识
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
About PHP startup, mongodb cannot find the specified module
随机推荐
【Postman】测试(Tests)脚本编写和断言详解
Expose the serial fraudster Liu Qing in the currency circle, and default hundreds of millions of Cheng Laolai
一文揭开,测试外包公司的真 相
曼哈顿距离和-打印菱形
Leaflet map
《卓有成效的管理者》读书笔记
单元测试的意义
数学三大核心领域概述:几何
A complete collection of necessary learning websites for office programmers
ICLR 2022 spotlight | analog transformer: time series anomaly detection method based on correlation difference
F - True Liars (种类并查集+DP)
还在为如何编写Web自动化测试用例而烦恼嘛?资深测试工程师手把手教你Selenium 测试用例编写
Postman核心功能解析-参数化和测试报告
php使用redis实现分布式锁
leaflet 地图
Understanding of processes and threads
[postman] collections configuration running process
黑猫带你学eMMC协议第10篇:eMMC读写操作详解(read & write)
isam2运行流程
LeetCode 1200. 最小绝对差