Code:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
main()
{
int box_id, i,col;
char input[100] = { "1312e7972714d01a46664a3523366a2f58560b42c485853674561c360d77" };
char sbox[8][16] = {
{ '2', '4', 'c', '5', '9', 'a', '3', '7', 'e', '1', '0', 'f', '8', '6', 'b', 'd' },
{ '7', 'e', 'a', '4', '1', 'd', '9', 'f', '2', 'b', '6', '0', 'c', '5', '8', '3' },
{ '3', '8', 'f', '1', 'a', '6', '5', 'b', 'd', 'e', '4', '2', '7', '0', '9', 'c' },
{ '8', 'f', '7', '9', '3', 'd', '4', 'b', 'c', '2', '0', 'a', '1', '5', '6', 'e' },
{ '1', 'f', '8', '3', 'c', '0', 'b', '6', '2', '5', '4', 'e', '9', 'a', '7', 'd' },
{ '1', 'd', 'f', '0', 'e', '8', '2', 'c', '7', '4', 'b', 'a', '3', '5', '9', '6' },
{ 'a', '3', '4', '7', 'b', '8', 'd', '2', '6', 'c', 'f', 'e', '0', '5', '1', '9' },
{ '3', 'c', '4', '2', '7', 'a', '0', '8', '5', 'b', 'f', '1', 'd', '6', '9', 'e' }
};
printf("%s", input);
printf("\n\n");
//srand(time(NULL));
//box_id=rand()%7;
//printf("%d\n\n\n",box_id);
for (i = 0; i < 60; i++)
{
if (input[i]=='a')
{
col = 10;
}
else if (input[i] == 'b')
{
col = 11;
}
else if (input[i] == 'c')
{
col = 12;
}
else if (input[i] == 'd')
{
col = 13;
}
else if (input[i] == 'e')
{
col = 14;
}
else if (input[i] == 'f')
{
col = 15;
}
else
{
col = i;
}
printf("%c", sbox[0][input[col]]);
}
printf("\n\n");
system("pause");