Skip to content

prathameshsail72-hue/password-strength-ml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

22 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ” Password Strength Detection using Machine Learning

๐ŸŒ Live Demo


๐Ÿ“Œ Overview

This project is a full-stack Machine Learning application that evaluates password strength in real time.

It combines:

  • ๐Ÿง  A trained ML model (Random Forest)
  • โšก A REST API built with FastAPI
  • ๐ŸŽจ An interactive UI built with Streamlit

Users can input a password and instantly get:

  • Strength classification (Weak / Medium / Strong)
  • Security insights (entropy, patterns)
  • Improvement suggestions

๐Ÿš€ Features

๐Ÿง  Machine Learning

  • Feature-engineered password analysis
  • Entropy-based complexity measurement
  • Random Forest classifier (multi-class)

โšก Backend (API)

  • REST API using FastAPI
  • JSON-based prediction endpoint (/predict)
  • Deployed on Render

๐ŸŽจ Frontend (UI)

  • Interactive UI using Streamlit
  • Password generator ๐Ÿ”
  • Strength score (0โ€“100)
  • Entropy calculation ๐Ÿ“Š
  • Real-time feedback & suggestions
  • API health monitoring

๐Ÿ“‚ Project Structure

password-strength-ml/
โ”‚
โ”œโ”€โ”€ assets/ # Screenshots
โ”œโ”€โ”€ data/ # Dataset (rockyou.txt)
โ”œโ”€โ”€ models/ # Trained model (.pkl)
โ”‚
โ”œโ”€โ”€ src/
โ”‚ โ”œโ”€โ”€ data_loader.py
โ”‚ โ”œโ”€โ”€ preprocessing.py
โ”‚ โ”œโ”€โ”€ feature_engineering.py
โ”‚ โ”œโ”€โ”€ model.py
โ”‚ โ”œโ”€โ”€ train.py
โ”‚
โ”œโ”€โ”€ api/
โ”‚ โ””โ”€โ”€ main.py # FastAPI backend
โ”‚
โ”œโ”€โ”€ streamlit_app.py # Streamlit frontend
โ”œโ”€โ”€ main.py # CLI prediction
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ README.md

๐Ÿ“Š Dataset

Download RockYou dataset from Kaggle and place it in:

data/rockyou.txt

  • RockYou password dataset (real-world leaked passwords)
  • Synthetic strong passwords generated programmatically

โš ๏ธ Note: Dataset contains weak passwords, so strong passwords are artificially generated to balance the dataset.


๐Ÿง  Feature Engineering

Password length Uppercase / lowercase count Digits & special characters Character ratios Entropy (randomness measure) Weak pattern detection ("123", "password") Repetition patterns


๐Ÿ“Š Model Details

Algorithm: Random Forest Classifier Library: scikit-learn Classes: 0 โ†’ Weak 1 โ†’ Medium 2 โ†’ Strong

๐Ÿ“Š Model Performance

๐Ÿ“ˆ Performance Accuracy: ~91% F1 Score: ~0.89


โš™๏ธ Installation

1. Clone the repository

git clone https://github.com/prathameshsail72-hue/password-strength-ml.git cd password-strength-ml

python -m venv venv venv\Scripts\activate # Windows

pip install -r requirements.txt

Run Backend (API) uvicorn api.main:app --reload

Visit: http://127.0.0.1:8000/docs

Run Frontend (Streamlit) streamlit run streamlit_app.py


๐Ÿ“ˆ Evaluation

The model is evaluated using:

  • Accuracy
  • Precision / Recall / F1-score

โš ๏ธ Limitations

No breach detection (e.g. leaked passwords) Rule-based + ML hybrid (not attack simulation) Synthetic strong passwords used for balancing Render free tier causes cold start delays


๐Ÿ“ธ Demo

Password Strength Predictions

Demo 1 Demo 2 Demo 3

Training Output

Output

Project Structure

Structure

๐ŸŒ Web App Demo (Streamlit)

Run the app locally:

bash streamlit run app.py

๐Ÿ”ฎ Future Improvements

๐Ÿ” Integrate Have I Been Pwned API ๐Ÿง  Deep Learning (LSTM / Transformers) ๐Ÿ“Š Confidence score output โšก Caching & performance optimization ๐ŸŒ Multi-language password analysis


๐Ÿค Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.


๐Ÿ“œ License

This project is open-source and available under the MIT License.


๐Ÿ‘จโ€๐Ÿ’ป Author

Prathamesh Sail GitHub: https://github.com/prathameshsail72-hue

About

End-to-end ML project for password strength detection using feature engineering and Random Forest, with CLI-based prediction.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages