Hex to Base32: Encode and Convert Online

in "Encoding"

Base-32 is basically a way of encoding arbitrary binary data in ASCII text. A base-32 encoded value only contains uppercase letters, digits and the equal sign as padding.

Such a value (excluding padding) can be included in an URL without encoding any characters.

Base-32 encoding schemes uses the 26 uppercase letters A – Z, and the digits 2 – 7. This encoding scheme is defined in the RFC 4648.

The 0 and 1 are skipped due to their similarity with the letters O and I.

How to convert hex to base-32

For example, lets base-32 encode the word “Cat”.

ASCII text conversion table:

ASCII


Hex


Symbol


0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F

NUL
SOH
STX
ETX
EOT
ENQ
ACK
BEL
BS
TAB
LF
VT
FF
CR
SO
SI


ASCII


Hex


Symbol


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

10
11
12
13
14
15
16
17
18
19
1A
1B
1C
1D
1E
1F

DLE
DC1
DC2
DC3
DC4
NAK
SYN
ETB
CAN
EM
SUB
ESC
FS
GS
RS
US


ASCII


Hex


Symbol


32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

20
21
22
23
24
25
26
27
28
29
2A
2B
2C
2D
2E
2F

(space)
!
"
#
$
%
&
'
(
)
*
+
,
-
.
/


ASCII


Hex


Symbol


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

30
31
32
33
34
35
36
37
38
39
3A
3B
3C
3D
3E
3F

0
1
2
3
4
5
6
7
8
9
:
;
<
=
>
?


ASCII


Hex


Symbol


64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

40
41
42
43
44
45
46
47
48
49
4A
4B
4C
4D
4E
4F

@
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O


ASCII


Hex


Symbol


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

50
51
52
53
54
55
56
57
58
59
5A
5B
5C
5D
5E
5F

P
Q
R
S
T
U
V
W
X
Y
Z
[
\
]
^
_


ASCII


Hex


Symbol


96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

60
61
62
63
64
65
66
67
68
69
6A
6B
6C
6D
6E
6F

`
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o


ASCII


Hex


Symbol


112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127

70
71
72
73
74
75
76
77
78
79
7A
7B
7C
7D
7E
7F

p
q
r
s
t
u
v
w
x
y
z
{
|
}
~


 

Cat in ASCII decimal values = [67, 97, 116]

“Cat” in binary format = [01000011, 01100001, 01110100].

If the data you have is in hexadecimal, you will have to convert hex to binary before you can convert hex to base-32.

After you convert your hex values to binary, the process is as follows:

Step 1. Convert an input byte stream into a group of 5 bytes. If there are less than 5 bytes, at the end, pad additional empty bytes.

Group = [01000011, 01100001, 01110100, XXXXXXXX, XXXXXXXX].

Step 2. Divide this group into 8 chunks of bits.

Chunks = [01000, 01101, 10000, 10111, 0100X, XXXXX, XXXXX, XXXXX].

Step 3. If a chunk has both actual bits and empty bits, replace the empty bits with 0’s.

Chunks = [01000, 01101, 10000, 10111, 01000, XXXXX, XXXXX, XXXXX].

Step 4. Convert each 5 bits chunk to its decimal value (0 – 31).

If a 5 bits chunk contains empty bits replace with character “=”.

Chunks = [8, 13, 16, 23, 8, =, =, =].

Step 5. In the base-32 symbol chart, map each decimal value to its corresponding character.

Chunks = [I, N, Q, X, I, =, =, =].

Base32 symbol chart

The BASE32 Alphabet

Char.

Dec.

Hex.

 

Char.

Dec.

Hex.

 

Char.

Dec.

Hex.

A

0

00

 

M

12

0C

 

Y

24

18

B

1

01

 

N

13

0D

 

Z

25

19

C

2

02

 

O

14

0E

 

2

26

1A

D

3

03

 

P

15

0F

 

3

27

1B

E

4

04

 

Q

16

10

 

4

28

1C

F

5

05

 

R

17

11

 

5

29

1D

G

6

06

 

S

18

12

 

6

30

1E

H

7

07

 

T

19

13

 

7

31

1F

I

8

08

 

U

20

14

 

 

 

 

J

9

09

 

V

21

15

 

=

(pad)

(pad)

K

10

0A

 

W

22

16

 

 

 

 

L

11

0B

 

X

23

17

 

 

 

 

BASE32 characters are 5 bits in length. They are formed by taking a block of five octets to form a 40-bit string, which is converted into eight BASE32 characters.

NOTE: The pad character (=) does not have a binary representation in BASE32; it is inserted into the BASE32 text as a placeholder to maintain 40-bit alignment.

When converting to binary, remember to use only 5 bits (e.g., 0x19 = binary 1 1001).

 

Above is the base-32 symbol chart. Look up the decimal value in the chart and find its corresponding character in the map.

Decimal value: 8, 13, 16, 23, 8 corresponds to: INQXI.

Step 6. The word “Cat” base-32 encoded is “INQXI===”.

Recommended Tools