Hex encode and decode

What is hexadecimal?

The hexadecimal number system is base sixteen which means that there are sixteen unique symbols used as digits. Recall that the decimal number system had ten symbols. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and the binary number system had two 0 and 1. The symbols used in the hexadecimal number system are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F and are used to represent number values of 0 through 15 respectively. This means that some of the numbers is the hexadecimal number system will look like words.

More on binary and hex conversion

Hex encoding usage

Some common examples are – Ip addresses, color codes,and mac addresses etc. Mainly used because it provides a more human-friendly representation.

The main one – for encoding, some channel works on (ASCII only) scheme one example of such channel is (URL), so to bypass them we need encoding schemes like hex and base64. Usually, they convert Non-ASCII to ASCII by this, they can be easily passed through (ASCII only) channel.

Base64 vs Hex encoding

Both scheme act same, both convert non ASCII characters to ASCII ones. But hex take more space, because it make a pair of 4 bits and replace it with single character (let’s take 24 bits, hex replace it with 6 character). While base64 form a pair of 6 bits and replace it with single character (24 bits means, base64 replace it with 4 characters), in terms of small sizing base64 rocks, and due to this used alot for transmission.