> For the complete documentation index, see [llms.txt](https://cajac.gitbook.io/ctf-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cajac.gitbook.io/ctf-notes/encoding-and-decoding/basex/base32.md).

# Base32

## Convert in bash

### Base32 decode

```bash
┌──(kali㉿kali)-[~]
└─$ echo 'MJQXGZJTGIQGS4ZAON2XAZLSEBRW63LNN5XCA2LOEBBVIRRHOM======' | base32 -d
base32 is super common in CTF's  
```

### Base32 encode

```bash
┌──(kali㉿kali)-[~]
└─$ echo 'This is a test!' | base32
KRUGS4ZANFZSAYJAORSXG5BBBI======
```

## Convert with Binary Refinery

You can convert from `base32` with [b32](https://binref.github.io/#refinery.b32) from Binary Refinery

```bash
┌──(kali㉿kali)-[~]
└─$ source ~/Python_venvs/Binary_Refinery/bin/activate

┌──(Binary_Refinery)─(kali㉿kali)-[~]
└─$ emit 'MJQXGZJTGIQGS4ZAON2XAZLSEBRW63LNN5XCA2LOEBBVIRRHOM======' | b32
base32 is super common in CTF's
```

## Convert in Python

### Base32 decode

```bash
┌──(kali㉿kali)-[~]
└─$ python                        
Python 3.11.9 (main, Apr 10 2024, 13:16:36) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import base64
>>> base64.b32decode(b'MJQXGZJTGIQGS4ZAON2XAZLSEBRW63LNN5XCA2LOEBBVIRRHOM======')
b"base32 is super common in CTF's"
>>> base64.b32decode(b'MJQXGZJTGIQGS4ZAON2XAZLSEBRW63LNN5XCA2LOEBBVIRRHOM======').decode()
"base32 is super common in CTF's"
>>> exit()
```

### Base32 encode

```bash
┌──(kali㉿kali)-[~/Desktop]
└─$ python
Python 3.11.9 (main, Apr 10 2024, 13:16:36) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import base64
>>> base64.b32encode(b'This is a test!')
b'KRUGS4ZANFZSAYJAORSXG5BB'
>>> exit()
```

## Convert with online services

You can also convert base32 with one of these online services:

CyberChef: <https://gchq.github.io/CyberChef/#recipe=From_Base32('A-Z2-7%3D',true)>

dcode.fr: <https://www.dcode.fr/base-32-encoding>

## Resources

Binary Refinery - Documentation: <https://binref.github.io/>

Binary Refinery - GitHub: <https://github.com/binref/refinery/>

Base32 - Wikipedia: <https://en.wikipedia.org/wiki/Base32>

base32 - Linux manual page: <https://man7.org/linux/man-pages/man1/base32.1.html>

base64 module - Python: <https://docs.python.org/3/library/base64.html>
