How to base64 encode and decode from command-line in Windowns

In this tutorial, we will learn how and why to use base64 encode from the command-line on Windowns using my own Base64 converter. You will also learn what base64 encoding is and why it may be used to compact data.

Murilothebr
2 min readAug 23, 2023

Why use base64

Base64 encoding is commonly used when you need to ensure that binary data can be safely transmitted and stored within systems that only support text data. This encoding provides a reliable way to represent binary information using a limited set of characters, making it suitable for scenarios where data integrity and compatibility are crucial

Why use this resolution to encode to base64

It’s pretty common when using base64 in Windows to rescore to websites, as there is no easy built-in way to perform this encoding, . However, when working with security files like a private key, it might be dangerous because we don’t know how those websites are using your data

How to Setup and use my base64 converter:

— I will not dispose the .exe directly, so DIY

1. Clone my project: https://github.com/Murilothebr/base64_dotnet

2. Build the project with: dotnet build

3. Enter in the bin folder

3. Copy those files to some other trusted folder, like your script’s folder.

4. Add the environment varible to use this in anywhere with, like:
— — setx PATH “%PATH%;C:/your/folder"

5. Try it running “base64 -h” in your cmd

Using the base64 script

Encode a string:

Try the following command to get some help

base64 -h

Encode a string:

Try the following command to encode a string

base64 -e your-string

Decode a string:

Try the following command to decode a string

base64 -d your-base64-string-from-before

Encode a file:

Try the following command to encode a file

base64 -e -f /your/file/path

Decode a file:

Try the following command to decode a file

base64 -d -f your-base64-file-from-before /your/decoded/file/path

--

--

Murilothebr

Estou sempre em busca de novos desafios, faço faculdade na UTFPR de Guarapuava, cursando Tecnologia de Sistemas para Internet e a minha paixão é a programação!