How the conversion works
There is no direct digit-by-digit mapping between hex and octal, so the standard approach uses binary as an intermediate step. First expand each hex digit into four binary bits, then regroup the full binary string into sets of three bits and translate each group to an octal digit.