As an advanced beginner in Python, I wanted to challenge myself to build something functional using just my smartphone. Using Pydroid 3, I developed a command-line Login and Registration system that enforces strict security rules and even includes a built-in master account recovery option.
Here is a breakdown of how the logic works under the hood:
- Data Sanitization and Validation Loops A major vulnerability in applications is empty user input. To combat this, I wrapped the registration steps in standalone while loops. Using Python's .strip() string method, the program shaves off empty spaces. If a user simply hits "Enter" or types blank spaces, the system detects it and refuses to advance until real characters are provided.
- Algorithmic Password Requirements Instead of standard inputs, this system uses built-in Python string methods to evaluate password complexity: The Length Check: By passing the stripped input into len(), the system strictly filters passwords to ensure they are exactly 8 characters—rejecting inputs that fall short or go over. Type Splitting: Using .isalpha() (all letters) and .isdigit() (all numbers), the script detects if the user is lazy with their security. If either condition evaluates to True, the script catches it and demands a mixed alphanumeric password.
- The Code Here is my complete, functional script. You can run this directly in Pydroid 3:
import time
print("=== Hi user, create your lock ===\n\n")
Step 1: Create Username
move = True
while move == True:
time.sleep(1)
name_set = input("Create a name: ")
nam = name_set.strip()
if nam == "":
print("Please write your name")
else:
move = False
Step 2: Create Password
time.sleep(0.5)
print("\nWrite a password exactly 8 characters long, using a combination of numbers and alphabets.\n")
run = True
while run == True:
password_set = input("Create a password: ")
space = password_set.strip()
alphabet_check = space.isalpha()
number_check = space.isdigit()
code = len(space)
if alphabet_check == True or number_check == True:
print("Please create your lock with numbers and alphabets")
elif password_set == "":
print("Please write your password")
elif code > 8:
print("Please, your password is more than 8 text")
elif code < 8:
print("Please, your password is less than 8 text")
else:
run = False
time.sleep(1)
print("\n=== Welcome " + name_set + " === \n")
# Step 3: Verify Login
running = True
while running == True:
time.sleep(0.5)
print("\nPlease provide your login details\n")
name = input("Name: ")
password = input("Password: ")
check_name = name.strip()
check_password = password.strip()
if check_name == nam and check_password == space:
print("Access granted")
running = False
elif check_name == "" or check_password == "":
print("Please fill out the login completely")
# Step 4: Master Recovery Code
elif check_name == "cc23akkee" and check_password == "cc23akkee":
print("\n--- Log Display ---")
print("Name: " + nam)
print("Password: " + space)
else:
print("Access denied")
- Verification Gate & Backdoor Recovery Once registered, the nested login verification loop fires up. The program acts as a strict conditional gate: Success: If check_name == nam and check_password == space, access is granted and the execution loop terminates safely. The Secret Recovery Protocol: I hardcoded an explicit administrative backdoor trigger (cc23akkee). If a user forgets their credentials, entering this master sequence into the login terminal bypasses standard validation and safely outputs the stored registration variables.
Conclusion:
Developing this program over forty-eight hours on a mobile terminal emphasizes that strong, logical backend frameworks don't require desktop hardware. Successfully managing nested validation states and variable comparisons keeps my engineering skills sharp as I dive deeper into Python automation scripts.
Top comments (0)