当前位置:网站首页>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 )
边栏推荐
- 黑猫带你学UFS协议第8篇:UFS初始化详解(Boot Operation)
- 全链路压测:构建三大模型
- Aike AI frontier promotion (2.13)
- 模拟卷Leetcode【普通】1405. 最长快乐字符串
- [wechat applet] build a development tool environment
- Eigen sparse matrix operation
- Database - current read and snapshot read
- Reading notes of effective managers
- 模拟卷Leetcode【普通】1109. 航班预订统计
- Simulation volume leetcode [general] 1062 Longest repeating substring
猜你喜欢
全链路压测:构建三大模型
[postman] test script writing and assertion details
进程和线程的理解
Buuctf-[bjdctf2020]zjctf, but so (xiaoyute detailed explanation)
ESP32 ESP-IDF看门狗TWDT
P问题、NP问题、NPC问题、NP-hard问题详解
Expose the serial fraudster Liu Qing in the currency circle, and default hundreds of millions of Cheng Laolai
What are the test sites for tunnel engineering?
[API interface tool] Introduction to postman interface
D - How Many Answers Are Wrong
随机推荐
Simulation volume leetcode [general] 1414 The minimum number of Fibonacci numbers with a sum of K
模拟卷Leetcode【普通】1143. 最长公共子序列
Caused by:org.gradle.api.internal.plugins . PluginApplicationException: Failed to apply plugin
模拟卷Leetcode【普通】1249. 移除无效的括号
B - The Suspects
【C语言】字符串左旋
10m25dcf484c8g (FPGA) amy-6m-0002 BGA GPS module
[postman] the monitors monitoring API can run periodically
D - How Many Answers Are Wrong
Basic knowledge of error
模拟卷Leetcode【普通】1447. 最简分数
Idea new UI usage
F - true liars (category and search set +dp)
黑猫带你学eMMC协议第10篇:eMMC读写操作详解(read & write)
Resttemplate and feign realize token transmission
An article was uncovered to test the truth of outsourcing companies
「 WEB测试工程师 」岗位一面总结
模拟卷Leetcode【普通】1062. 最长重复子串
RestTemplate、Feign实现Token传递
自定义指定路由上的Gateway过滤器工厂