Introduction
In this blog, I’m going to show you how to encode and decode passwords using Python’s Base64 module. Many beginners think that Base64 is encryption, but that’s NOT true! Base64 is just an encoding technique that converts data into a different format, which can be easily decoded back.
So let’s dive into the world of encoding & decoding! 😎
इस ब्लॉग में आप क्या सीखेंगे?
इस ब्लॉग में मैं आपको Python के Base64 module का इस्तेमाल करके पासवर्ड को encode और decode करना सिखाने वाला हूँ।बहुत से beginners को लगता है कि Base64 एक encryption method है, लेकिन ऐसा नहीं है! Base64 सिर्फ encoding होती है, जो data को एक अलग format में बदल देती है जिसे आसानी से decode किया जा सकता है।
तो चलिए, encoding और decoding की दुनिया में गोता लगाते हैं! 😎

Requirements (Before You Start Encoding/Decoding)
1) Python 3.x Installed
First things first – your system must have Python 3.x installed. Without it, your script won’t run, and you’ll be stuck just watching the show.
1) Python 3.x Install होना चाहिए
सबसे पहले आपके system में **Python 3.x install होना ज़रूरी है।**अगर यह नहीं होगा, तो आपकी script चलेगी ही नहीं — और आप बस देखते रह जाओगे 😅 इसलिए Python को पहले install ज़रूर कर लें।
2) Basic Knowledge of Python
We’ll be using functions, input handling, and encoding/decoding methods. If you know how to write and execute a simple Python script, you are good to go!
2) Python की Basic Knowledge होनी चाहिए
हमें Python के functions, input handling और encoding/decoding methods का उपयोग करना होगा।अगर आप एक simple Python script लिख और चला सकते हैं, तो आप इस blog को आसानी से समझ सकते हैं! 😍
Step 1: Encoding Password in Base64
Before we decode passwords, we first need to encode them. Encoding converts your password into a different format that looks unreadable.
पासवर्ड को decode करने से पहले, हमें उसे encode करना होगा।Encoding आपके पासवर्ड को unreadable format में बदल देता है।
🛠 Python Code for Encoding:
Let’s create a password encryption program
# Let’s create a password encryption program
import base64
def encrypt_pass(password):
encoded_bytes = base64.b64encode(password.encode())
print(encoded_bytes)
user_pass = input(“Enter your password: “)
encrypt_pass(user_pass)

How It Works?
base64.b64encode: encodes the password into Base64 format.
decode() : converts the encoded bytes into a readable string.
Example Output:

Step 2: Decoding Password in Base64
Now, let’s decode the Base64-encoded password back into its original form.
🛠 Python Code for Decoding:
import base64
def decode_pass(password):
decode_bytes = base64.b64decode(password)
decode_data = decode_bytes.decode()
print(f”decoded password {decode_data}”)
encode_string = input(“enter the base64 string:”)
decode_pass(encode_string)

How It Works?
base64.b64decode(): decodes the Base64-encoded string.
decode(): converts it back into the original password.
Example Output:

Base64 is NOT Secure!
Base64 is NOT encryption! If a hacker gets your encoded password, they can easily decode it.
For real security, use hashing (like SHA-256) or encryption (like AES).
⚠️ Base64 कोई encryption नहीं है! अगर किसी hacker के पास Base64 encoded पासवर्ड आ जाए, तो वो इसे आसानी से decode कर सकता है।
अगर आपको secure पासवर्ड स्टोरेज चाहिए, तो hashing (SHA-256) या encryption (AES) का उपयोग करें।
Secure Alternative: SHA-256 Hashing
#code
import hashlib
def hash_password(password):
hashed = hashlib.sha256(password.encode()).hexdigest()
print(f”Hashed Password: {hashed}”)
user_pass = input(“Enter your password: “)
hash_password(user_pass)

OUTPUT

Conclusion
Base64 encoding is simple but NOT secure.
If you need to store passwords securely, use hashing (SHA-256) instead.
Base64 should only be used for data transformation, not security.
Base64 encoding आसान है, लेकिन सुरक्षित नहीं है।
अगर आपको सिर्फ encode/decode करना है, तो Base64 इस्तेमाल करें।
अगर आपको असली सुरक्षा चाहिए, तो hashing (SHA-256) या encryption (AES) का उपयोग करें।
![]()
