I'm creating an encryption function with a bit operator on both sides of the server client.
There was a problem with changing CString to char. After debugging, the sizeof(arr) value is only imported to 8.
I need to encrypt the buff length of the data I received, but I only calculate 8 pieces
Also, if it is larger than the length of the key, we have to calculate it from the beginning, but there seems to be a problem with the length here.
What is the cause and how should I correct it?
Function
char Encryption(char strEncordeData[])
{
m_socket_comm.encrypt[0] = '\0';
int length = sizeof((char*)strEncordeData);
int j = 0;
for (int i = 0; i < length; i++)
{
m_socket_comm.encrypt[i] = strEncordeData[i] ^ m_socket_comm.key[i];
if (i > sizeof(m_socket_comm.key) || j > sizeof(m_socket_comm.key))
{
m_socket_comm.encrypt[i] = strEncordeData[i] ^ m_socket_comm.key[j];
}
int j = i - sizeof(m_socket_comm.key);;
}
return *strEncordeData;
}
variable
char key[BUFSIZE] = "key";
char encrypt[BUFSIZE];
char decrypt[BUFSIZE];
Use sample
char pstr[BUFSIZE];
ZeroMemory(pstr, BUFSIZE);
m_edit_chat.GetWindowText(str2);
strcpy(pstr, str2);
for (int i = 0; i < m_socket_comm.client_list.size(); i++)
{
tcpserver.ServCurSelSend(i, pstr, sizeof(pstr));
}