What Is Base64 and How To Encode and Decode Text? – POFTUT

What Is Base64 and How To Encode and Decode Text?

Base64 is an encoding and decoding algorithm. We need the encoding of some data in order to prevent storing and transmission problems. For example, If we try to transfer binary data it may create and affect some network devices because of its data structures. Base64 is generally used different applications like email and MIME, XML, JSON, URL, and HTTP, etc.

Data Presentation

Base64 uses alphabet, numbers and = for encoded data. For example, the following examples are valid Base64 encoded data


And following are not valid encoded data


Base64 Is Not Encryption

Base64 is just encoding format so it is not used to encrypt data to hide from third parties. Base64 encoded data can be easily reverted or decoded back to the text format. It can work two way without a security restriction of password.

Linux Base64

Now we will look some examples about to encrypt and decrypt Base64 in Linux bash environment.


We will encode file contents named data.txt with base64 command. We do not provide any option for this.

$ base64 data.txt


Decoding is very similar to encode we will just provide -d option to the base64 command like below. In this example, we will use a file named encoded.txt which contains base64 encoded data.

$ base64 -d encoded.txt

Javascript Base64

Javascript provides btoa and atob() functions which are a short form of binary to ascii and ascii to binary . We will just provide the text or data we want to convert to these functions like below.



PHP Base64

In PHP Programming language we can use base64_encode  and base64_decode  functions like below.



LEARN MORE  Base64 and Default Password Projects

Leave a Comment