Home > Back-end >  VC turn C, to encrypt data decryption, Chinese is a question mark, and Numbers in English is normal
VC turn C, to encrypt data decryption, Chinese is a question mark, and Numbers in English is normal

Time:09-16

//make key 
Memset (key_des, 0, 9);
Sprintf (temp (char *), "% s", W2A (keystring));
If (len_keystring & gt;=iSize)
Memcpy (key_des, temp, iSize);
The else
Memcpy (key_des, temp, len_keystring);

Sprintf (temp (char *), "% s", W2A (content));
Memset (tempout, 0409, 6);
For (I=0, j=0; Len_instring & gt; 0; Len_instring -=iSize * 2, I +=iSize * 2, j +=iSize)
{
HstrToChr (unsigned char (*) (temp + I), iSize * 2, res);
Crypt_decrypt (je, res, key_des, des);
Des [8]='\ 0';
Memcpy (tempout + j, des, iSize);
}

* outstring=A2BSTR (tempout (char *));


Method parameters (BSTR mark, BSTR in BSTR keystring, BSTR * outstring) keystring is the key content is the data
After I modified into c + + (QT), the content and keystring is a QString
//make key 


Memset (key_des, 0, 9);

Char * ch_keystring;
QByteArray ba_in_keystring=keystring. ToLatin1 ();
Ch_keystring=ba_keystring. Data ();


Char * ch_content;
QByteArray ba_content=content. toLatin1 ();
Ch_content=ba_in. Data ();

Sprintf (temp (char *), "% s", ch_keystring);

If (len_keystring & gt;=iSize)
Memcpy (key_des, temp, iSize);
The else
Memcpy (key_des, temp, len_keystring);


Sprintf (temp (char *), "% s", ch_content);

Memset (tempout, 0409, 6);

For (I=0, j=0; Len_instring & gt; 0; Len_instring -=iSize * 2, I +=iSize * 2, j +=iSize)
{
HstrToChr (unsigned char (*) (temp + I), iSize * 2, res);
CryptDecrypt (je, res, key_des, des);
Des [8]='\ 0';
Memcpy (tempout + j, des, iSize);
}

QDebug () & lt; & lt;" Tempout "& lt;


Decoding out the results
| J702414 | 2018?? 08?? 21?? |????????????????????????????????? |
For the question mark in Chinese, English and digital normal








CodePudding user response:

Excuse me, what's the problem?

CodePudding user response:

If the character encoding output window can print Chinese characters,

CodePudding user response:


Print each char 0 xff16 into system, contrast