Unless there is some redundancy in your 16 hexadecimal character input, what you are asking is mathematically impossible. You can prove this by examining the entropy of your inputs.
- You have 16 hexadecimal characters.
16^16 = 18446744073709551616 ≈ 1.84x10^19 possible values.
- You want the string to be 6 upper (or lower - the maths is the same) case characters or fewer. In English (I assume you want English) there are 26 uppercase characters.
26^6 = 308915776 ≈ 3.09x10^8 possible values.
To guarantee that you can represent every one of your 16 hexadecimal characters, you need 14 upper (or lower) case letters.
13 characters isn't enough:
26^13 = 2481152873203736575 ≈ 2.48x10^18 possible values.
- 14 characters will suffice:
26^14 = 64509974703297150976 ≈ 6.45x10^19 possible values.
- The only way you could possibly do it (assuming no redundancy) in six (or fewer) characters is to have some base where each character has 1626 possible values.
1626^6 = 18480905552168525376 ≈ 1.849x10^19 possible values.
Shortening 32 hexadecimal characters to 12 or fewer upper (or lower) case characters is impossible by the same logic. Without redundancy, you can't guarantee that you can shorten any arbitrary 16 (or 32) hexadecimal characters into 6 (or 12) upper (or lower) case characters.