What Is Base64 and How To Encode and Decode Text?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/what-is-base64-and-how-to-encode-and-decode-text/
PINTEREST
PINTEREST
INSTAGRAM

Base64 is an encoding and decoding algorithm. We need 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 aphabet, numbers and = for encoded data. For example 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.

Encode

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

Linux Bash Encode
Linux Bash Encode

Decode

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

Linux Bash Decode
Linux Bash Decode

Javascript Base64

Javascript provides btoa and atob() functions which is 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.

LEARN MORE  How To Generate Random Numbers and Password with OpenSSL Rand

PHP Base64

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

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/what-is-base64-and-how-to-encode-and-decode-text/
PINTEREST
PINTEREST
INSTAGRAM