Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
int encfile(FILE *fin, FILE *fout, aes_encrypt_ctx ctx[1])
{   unsigned char dbuf[3 * BLOCK_LEN],b;
    unsigned long i, len, wlen = BLOCK_LEN;
 
    // set a random IV
 
    fillrand(dbuf, BLOCK_LEN);
 
    // read the first file block
    len = (unsigned long) fread((char*)dbuf + BLOCK_LEN, 1, BLOCK_LEN, fin);
 
    if(len < BLOCK_LEN)
    {   // if the file length is less than one block
 
		printf("len<16 len= %d\n",len);
        // xor the file bytes with the IV bytes
        for(i = 0; i < len; ++i)
            dbuf[i + BLOCK_LEN] ^= dbuf[i];
		b=dbuf[16];
		printf("dbuf[%d]= %s \n",i,b);
 
//....
//... le reste du code n'est pas important
//...
Quand je tente d'afficher b avec printf("dbuf[%d]= %s \n",i,b); j'obtiens :
Segmentation fault (core dumped)
Pourqoi ?Comment afficher l'unsigned char dbuf ?[/code]