我想使用 AES 算法。
我在上面使用这个功能
void SubBytes(char *SArr[4][4]){
int r,c;
char xlook[2];char ylook[2]; char hexStr[2]; char *Pad;
int intxlook,intylook;
char *temp;
int subbyte;
Pad = (char *)malloc (sizeof(char));
temp = (char *)malloc (sizeof(char));
for (r = 0; r < 4; r++)
for(c = 0; c < 4; c++){
strcpy(temp,"");
strcpy(xlook,"");strcpy(ylook,"");
strcpy(temp,SArr[r][c]);
xlook[0] = temp[0]; xlook[1] = '\0';
ylook[0] = temp[1];ylook[1] = '\0';
intxlook = string_to_dec(xlook);
intylook = string_to_dec(ylook);
subbyte = SBox(intxlook,intylook);
itoa(subbyte,hexStr,16);
if (strlen(hexStr) < 2){
strcpy(Pad,"");
Pad = Padding(0,1);
strcat(Pad,hexStr);
strcpy(SArr[r][c],Pad);
}
else
strcpy(SArr[r][c],hexStr);
}
//free(temp); free(Pad);
} //end
但我得到错误
围绕变量 'hexStr' 的堆栈在 c 中已损坏