as in the title, and each element of the array iv should contain a random number between 0 and 255 . I have tried like:
char iv[8];
char buf[2];
int i, k;
srand(time(NULL));
for (i = 0; i <8; i++){
k = rand()%256;
iv[i] = (char)k;
}
Thanks in advance.
You should use
unsigned charfor the array, notchar. The former is guaranteed to be able to hold the values from 0 to (at least) 255, but the latter may not be able to hold numbers greater than 127.