I need to realize this method (https://en.wikipedia.org/wiki/Padding_%28cryptography%29#PKCS7) using C, which don't have convenient function to do that.
I have added this way
int main()
{
FILE *file=fopen("1.xlsx", "a");
file_add(16,file);
fclose(file);
}
void file_add(int SizeOfBlock, FILE *file )
{
fseek(file, 0, SEEK_END);
int size = ftell(file); // file size in bytes
fseek(file, 0, SEEK_SET);
int diff = size%SizeOfBlock;
char arr[16] = "0000000000000000"; //16 zeroes
fwrite(arr, SizeOfBlock-diff, 1 , file); // here I added to end of file missing 0 to make size of file be dividing to SizeOfBlock
}
void file_remove (int SizeOfBlock, FILE *file)
{
// by this function I need to delete these zeroes
// max amount of zeroes is limited by SizeOfBlock
}
How can I do that? SizeOfBlock
can be only 8 or 16