我想用 PKCS7 做填充:
char *test1 = "azertyuiopqsdfgh";
char *test2 = malloc(32*sizeof(char));
memcpy(test2, test1, strlen(test1));
char pad = (char)(32-strlen(test1));
printf("pad = %d\n", pad);
for(int i = strlen(test1) ; i < 32 ; i++) {
test2[i] = pad;
}
for (int i = 0 ; i < 32 ; i++)
printf("%x ", test2[i]);
printf("\n");
我得到:
pad = 16
61 7a 65 72 74 79 75 69 6f 70 71 73 64 66 67 68 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
但我想要 :
pad = 16
61 7a 65 72 74 79 75 69 6f 70 71 73 64 66 67 68 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16 16
我怎样才能修改我的代码?
提前致谢。