当前位置:网站首页>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加盐后注册码)
边栏推荐
- GTSAM中李群的运用
- MPLS test report
- Embedded point test of app
- Aike AI frontier promotion (2.13)
- 黑猫带你学UFS协议第4篇:UFS协议栈详解
- G - Supermarket
- 测试周期被压缩?教你9个方法去应对
- Cannot create PoolableConnectionFactory (Could not create connection to database server. 错误
- Database - current read and snapshot read
- [API interface tool] Introduction to postman interface
猜你喜欢
随机推荐
调用链监控Zipkin、sleuth搭建与整合
Seven imperceptible truths in software testing
自定义指定路由上的Gateway过滤器工厂
Idea new UI usage
[untitled]
[API interface tool] Introduction to postman interface
假设检验学习笔记
P问题、NP问题、NPC问题、NP-hard问题详解
B - The Suspects
Manage configuration using Nacos
10M25DCF484C8G(FPGA) AMY-6M-0002 BGA GPS模块
Embedded point test of app
黑猫带你学UFS协议第18篇:UFS如何配置逻辑单元(LU Management)
The latest 2022 review of "graph classification research"
Sqlmap tutorial (III) practical skills II
Fault, error, failure of functional safety
LeetCode 739. 每日温度
[C language] string left rotation
多线程应用的测试与调试
Win10 cannot operate (delete, cut) files