- Hacking RSA Cipher
- RSA Cipher Decryption
- RSA Cipher Encryption
- Creating RSA Keys
- Understanding RSA Algorithm
- Symmetric & Asymmetric Cryptography
- Implementation of One Time Pad Cipher
- One Time Pad Cipher
- Implementing Vignere Cipher
- Understanding Vignere Cipher
- Python Modules of Cryptography
- Decryption of Simple Substitution Cipher
- Testing of Simple Substitution Cipher
- Simple Substitution Cipher
- Hacking Monoalphabetic Cipher
- Affine Ciphers
- Multiplicative Cipher
- XOR Process
- Base64 Encoding & Decoding
- Decryption of files
- Encryption of files
- Decryption of Transposition Cipher
- Encryption of Transposition Cipher
- Transposition Cipher
- ROT13 Algorithm
- Caesar Cipher
- Reverse Cipher
- Python Overview and Installation
- Double Strength Encryption
- Overview
- Home
Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Base64 Encoding and Decoding
Base64 encoding converts the binary data into text format, which is passed through communication channel where a user can handle text safely. Base64 is also called as Privacy enhanced Electronic mail (PEM) and is primarily used in email encryption process.
Python includes a module called BASE64 which includes two primary functions as given below −
base64.decode(input, output) − It decodes the input value parameter specified and stores the decoded output as an object.
Base64.encode(input, output) − It encodes the input value parameter specified and stores the decoded output as an object.
Program for Encoding
You can use the following piece of code to perform base64 encoding −
import base64 encoded_data = base64.b64encode("Encode this text") print("Encoded text with base 64 is") print(encoded_data)
Output
The code for base64 encoding gives you the following output −
Program for Decoding
You can use the following piece of code to perform base64 decoding −
import base64 decoded_data = base64.b64decode("RW5jb2RlIHRoaXMgdGV4dA==") print("decoded text is ") print(decoded_data)
Output
The code for base64 decoding gives you the following output −
Difference between ASCII and base64
You can observe the following differences when you work on ASCII and base64 for encoding data −
When you encode text in ASCII, you start with a text string and convert it to a sequence of bytes.
When you encode data in Base64, you start with a sequence of bytes and convert it to a text string.
Drawback
Base64 algorithm is usually used to store passwords in database. The major drawback is that each decoded word can be encoded easily through any onpne tool and intruders can easily get the information.
Advertisements