如果最后一次通话是< 16个字节我用0填充缓冲区
这是一个正确的方法吗?
FILE *fp = fopen("name", "r+");
FILE *fpout = fopen("name", "w+");
char plain_text[16];
fseek(fp, 0, SEEK_SET);
while(!feof(fp)){
memset(plain_text, 0, sizeof(plain_text);
read_bytes = fread(plain_text, 1, 16, fp);
if(read_bytes < 16){
i = read__bytes;
read_bytes += 1;
for(i, i<16, i++) plain_text[read_bytes] = 0;
}
encrypt-this-part-of-file
fwrite(encBuffer, 1, 16, fpout);
}
答案 0 :(得分:4)
if(read_bytes < 16)
{
for(i = read_bytes; i<16; i++)
{
plain_text[i] = 0;
}
}
...如果你真的需要它。
但是你不需要将数组的剩余部分归零,因为你已经用...清除它了
memset(plain_text, 0, sizeof(plain_text));
......你在每次犯罪之前都在打电话。