Base64 encoding and decoding is used when there needs to transfer or store data. Base64 converts text data into binary data.
Every programming language has own functions to encode and decode in Base64 format. Python language uses base64 module to easily methods to encode and decode in base64 format.
First create base64_encode.py file and paste the below code.
import base64
text_data = "This is text message"
ascii_data = text_data.encode('ascii')
base64_byte_data = base64.b64encode(ascii_data)
encoded_data = base64_byte_data.decode('ascii')
print(encoded_data)
Now run the command in Terminal to see output of encoded data.
python3 base64_encode.py
VGhpcyBpcyB0ZXh0IG1lc3NhZ2U=
To decode base64, same way create base64_decode.py file and put the below code.
import base64
encoded_data = "VGhpcyBpcyB0ZXh0IG1lc3NhZ2U="
base64_byte_data = encoded_data.encode('ascii')
ascii_data = base64.b64decode(base64_byte_data)
text_data = ascii_data.decode('ascii')
print(text_data)
And run the command in Terminal to see decoded data.
python3 base64_decode.py
This is text message
I hope it will help you.
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
How to Build a Chrome Extension
Extensions in Google chrome and Add-ons...Laravel 8 - Livewire CRUD with Bootstrap Modal
In this article, I would really like to...Passwordless Login with Laravel 8
Laravel provides simple authentication s...Laravel 8 Roles and Permissions Tutorial Part 2
In the previous tutorial article, we hav...How to Export whole table to CSV using laravel
In this article, i will share with you h...