Python is a programming language that is easy to learn and powerful. Python has an efficient high-level data structure and approach to simple but effective object-oriented programming (OOP). elegant python syntax and typing dynamics, together with its interpreted nature, make python an ideal language for scripting programming and rapid application development in various fields and almost all platforms.
Python is one of high-level programming language that is intrepreter, interactive, object oriented and can operate on almost any platform, such as UNIX family, Mac, Windows, OS / 2, or other.as a high-python high language including one of the programming languages which is easy to learn because of its clear and elegant syntax, combined with the use of ready-to-use modules and efficient high-level data structures.
Base64 is a method used to encoding binary data so that it becomes "printable" or in short binary data is encoded into a 7-bit character format such as part of the email content.
I will only explain the basic meaning of a base64, because if we explain it will be very long or you can also read it complete on Wikipedia http://en.wikipedia.org/wiki/Base64.
So, essentially Base64 is a code composed by 64 characters, whose character (based on: RFC 1421) consists of (A-Z, a-z, 0-9, +, /) or "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 + /". But there is one extra character that is "=", whose function is to fulfill or term it as a filler pad.
So you are not confused to learn about encode and decode base64 using python, let's follow my steps as follows:
As we know, to start python coding, you have to install python version 2 application. After you install open COMMAND PROMT or CMD if you use WINDOWS, because the author uses Windows then to start it is using CMD or Command Promt or you can follow my steps like this:
Step 1 : Select Start Windows
Step 2 : Choose All Programs
Step 3 : Then find the Python folder, Here the author uses Python 2.7
Step 4 : Next click on the Python folder, then select Python (command line).
After that it will appear Python command line, as follows:
After following the steps as above, then next we will make encode and decode base64.
As we know that the activity of encode and decode is to secure the secret writing and reading the writings that are confidential, therefore the author wants to make the writing to be encoded and decoded with base64 is:
encode : tutorialencodedandecodebase64withpython
decode : dHV0b3JpYWxlbmNvZGVkYW5kZWNvZGViYXNlNjR3aXRocHl0aG9u
Type this script in the command line to encode "tutorialencodedandecodebase64withpython"
import base64
data = base64.b64encode("tutorialencodedandecodebase64withpython")
data
That is the result of the writing we have encoded earlier. dHV0b3JpYWxlbmNvZGVkYW5kZWNvZGViYXNlNjR3aXRocHl0aG9u
The next step is, how to decode writing that has been encoded earlier.
Type this script in the command line to decode
"dHV0b3JpYWxlbmNvZGVkYW5kZWNvZGViYXNlNjR3aXRocHl0aG9u "
to do the same decode as well as the first step, just change the syntax encode to decode see the following syntax :
data = base64.b64decode("dHV0b3JpYWxlbmNvZGVkYW5kZWNvZGViYXNlNjR3aXRocHl0aG9u")
data
After we do the decode then out the posts we have encode earlier that is : tutorialencodedandecodebase64withpython