Skip to content

utkarsh-tekriwal/MPIN-Validator

Repository files navigation

🔐 MPIN Validator

A Python-based tool to evaluate the strength of 4-digit or 6-digit MPINs by checking for:

  1. Commonly used PIN patterns (e.g., 1234, 0000, 2580)
  2. Demographic-based sequences derived from the user’s personal/family dates (DOBs, anniversary)

If a PIN is weak, the tool flags the exact reasons why it is considered insecure.


✅ Key Features

  • Fast checks using hash-based set and dict lookups
  • 🔍 Detects common patterns: repeated digits, sequences, mirrored and keypad-based entries
  • 🔐 Matches against user-specific date chunks like DD, MM, YY, YYYY
  • 🧠 Uses bit masking to identify all origins of date-based weakness
  • 🧪 Runs against a file of test cases with pass/fail reporting
  • 📜 Output includes exact reasons like:
    • COMMONLY_USED
    • DEMOGRAPHIC_DOB_SELF
    • DEMOGRAPHIC_SPOUSE
    • DEMOGRAPHIC_ANNIVERSARY

📁 Project Structure

MPIN-Validator/
├── demo_screen
  ├── demo1.png            # A demo Snapshot of code output
├── app.py                 # Main runner script for test execution
├── commonSeq.py           # Checks MPIN against known common patterns
├── demographicSeq.py      # Checks MPIN against date-based demographic patterns
├── test_cases.txt         # Contains test cases with expected results
├── common_pins.txt        # Comma-separated list of weak/common PINs
├── LogicalApproach.pdf    # PDF which explains the logic and approach used in the project
├── README.md              # Project documentation (this file)

🧠 Logic Overview

1. 🔁 Common Pattern Check

  • commonSeq.py loads all known weak MPINs from common_pins.txt into a set.
  • MPIN is looked up in constant time using:
    mpin in common_pins_set

2. 📅 Demographic Sequence Check

  • demographicSeq.py analyzes MPIN using user-supplied dates:
    • self_dob, spouse_dob, anniversary
  • From each date, it extracts: DD, MM, YYYY, and YY
  • Each chunk is stored in a dictionary with a bitmask integer value indicating origin(s)
  • MPIN is split into chunks like:
    • 4-digit → [2,2]
    • 6-digit → [2,2,2], [2,4], [4,2]
  • If all parts of MPIN matches date chunks stored in dictionary, the bitmask is returned indicating the source(s).

Example:

"1309"chunks: "13", "09"
chunk_map["13"] = 101present in Self DOB & Anniversary

3. 🚀 Test Runner

  • app.py:
    • Loads each test case from test_cases.txt
    • Feeds data into both checkers
    • Compares actual vs expected strength and reasons
    • Prints result per case:
      Test 1: Expected: WEAK ['COMMONLY_USED'], Got: WEAK ['COMMONLY_USED'] ✅ SUCCESS
      

📌 Technologies Used

  • Language: Python 🐍
  • Data Structures:
    • set() for common PINs (O(1) lookup)
    • dict() for chunk mapping and origin-tracking
  • Performance:
    • Space Complexity: O(n) for common PINs; O(1) elsewhere
    • Time Complexity: O(n) for initial loading; O(1) per PIN check

🖼️ Demo Screenshots

Model UI

Upload

🧪 Sample Test Case Format

Inside test_cases.txt:

1,1111,01012000,02022000,12102004,WEAK,['COMMONLY_USED']
2,1507,01012000,15072000,12122020,WEAK,['DEMOGRAPHIC_SPOUSE']
3,8462,01012000,15072000,12122020,STRONG,[]

🚀 Running the Project

# 1. Clone the repo
git clone https://github.com/utkarsh-tekriwal/MPIN-Validator.git
cd MPIN-Validator

# 2. Make sure Python is installed

# 3. Run the main test runner
python app.py

📧 Contact

Utkarsh Tekriwal
📫 utkarshtekriwal0013@gmail.com
🌐 GitHub


About

A Python tool to validate MPIN strength using pattern and demographic analysis

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages