I am trying to create all iterations for a cryptography key. I've the following code:
unsigned int key[6] = {0x0,0x0,0x0,0x0,0x0,0x0};
int count = 0;
for (int i = 0; i < 6; i++) //iterate through key
{
for (int j = 0; j < 256; j++)
{
key[i] = j;
for (int i = 0; i < 6; i++)
{
printf("%02x", key[i]);
}
printf("\n");
}
}
It only iterated through one item at a time from left to right and doesn't create all permutations i.e. if it was binary the above goes:
000 100 110 111
instead of 000 100 010 110 001 101 011 111
Is there an easy way to loop through all keys easily without tripping up over for loops? Thanks, Liam.
incfunction should work no matter what though.