Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions password_strength_checker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Password Strength Checker

A simple C program that evaluates the strength of a password based on various criteria.

## Description

This program analyzes a password and determines its strength based on the following factors:
- Presence of uppercase letters
- Presence of lowercase letters
- Presence of digits
- Presence of special characters
- Minimum length of 8 characters

## Features

- Real-time password strength evaluation
- Three strength levels: Weak, Medium, and Strong
- Simple command-line interface
- Character type detection (uppercase, lowercase, digits, special characters)

## Compilation

To compile the program, use any C compiler such as GCC:

```bash
gcc password_checker.c -o password_checker
```

## Usage

Run the compiled program:

```bash
./password_checker
```

Enter your password when prompted. The program will analyze it and display the strength level.

### Example

```
Enter your password: MyP@ss123

Password Strength: Strong
```

## Strength Criteria

The program calculates strength based on a scoring system (0-5 points):

- **Weak** (0-2 points): Password lacks multiple character types or is too short
- **Medium** (3-4 points): Password has good variety but may be missing some criteria
- **Strong** (5 points): Password meets all criteria including length and character variety

### Scoring Breakdown
- 1 point: Contains uppercase letters
- 1 point: Contains lowercase letters
- 1 point: Contains digits
- 1 point: Contains special characters
- 1 point: Length is 8 or more characters

## Limitations

- The program uses `scanf("%s", password)` which stops at whitespace, so passwords containing spaces cannot be fully tested
- Maximum password length is limited to 99 characters
- No buffer overflow protection beyond the array size
- Doesn't check against common password lists or patterns

## Security Note

This is a basic educational tool for demonstrating password strength concepts. For production applications, use established password validation libraries and follow current security best practices.

## Requirements

- C compiler (GCC, Clang, or similar)
- Standard C library with `stdio.h`, `string.h`, and `ctype.h`

## License

Free to use and modify for educational purposes.
45 changes: 45 additions & 0 deletions password_strength_checker/password-strength-checker.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>

#define MAX_PASSWORD_LENGTH 100
#define MIN_PASSWORD_LENGTH 8

int main() {
char password[MAX_PASSWORD_LENGTH];
size_t length = 0;
int upper = 0;
int lower = 0;
int digit = 0;
int special = 0;

printf("Enter your password: ");
scanf("%99s", password); // Safe input, avoids buffer overflow

length = strlen(password);

for (size_t i = 0; password[i] != '\0'; i++) {
if (isupper(password[i])) {
upper = 1;
} else if (islower(password[i])) {
lower = 1;
} else if (isdigit(password[i])) {
digit = 1;
} else {
special = 1;
}
}

int strength = upper + lower + digit + special + (length >= MIN_PASSWORD_LENGTH ? 1 : 0);

printf("\nPassword Strength: ");
if (strength <= 2) {
printf("Weak\n");
} else if (strength == 3 || strength == 4) {
printf("Medium\n");
} else {
printf("Strong\n");
}

return 0;
}