Hmm, do you know how to convert from decimal to base 6? You just modulate the number by 6, and use that value as the base6 index to get the correct character, than divide the value by 6.
Code:
int main()
{
char out[25] = {0};
int testVal = 393;
const char base6[6] = {
'0', '1', '2', '3', '4', '5'
};
char* ptr = &out[24];
for(; ptr >= out; --ptr)
{
*ptr = base6[testVal % 6];
testVal /= 6;
}
//test the result
size_t i = 0;
while(i < sizeof(out))
printf("%c", out[i++]);
return 0;
}
It requires a bit more to convert a large number like 128-bit.