PHP Classes

File: tests/StrengthCheckerTest.php

Recommend this page to a friend!
  Classes of John Conde   PHP Password Validation Helper   tests/StrengthCheckerTest.php  
File: tests/StrengthCheckerTest.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Password Validation Helper
Generate and check a password according to rules
Author: By
Last change: feat: Refactor password strength scoring to use a 1-100 scale

This commit introduces a comprehensive scoring system for password strength, replacing the previous categorical approach. The new system evaluates passwords based on four key factors:

- Length (up to 30 points): Rewards passwords between 8 and 20 characters.
- Character Variety (up to 30 points): Awards points for using uppercase, lowercase, numbers, and special characters, with bonuses for mixed case and multiple character types.
- Complexity (up to 20 points): Checks for repeated characters, sequential patterns, common passwords, and dictionary words.
- Entropy (up to 20 points): Calculates password entropy based on character set size and length.

Key improvements:
- Early returns for empty and very short passwords (score of 1)
- Robust checks for common patterns and keyboard sequences
- Comprehensive test suite using data providers
- Type-safe implementation with strict return types

The scoring system now provides a more granular and accurate assessment of password strength, making it easier to enforce security policies and guide users toward stronger passwords.

Tests: 60 tests, 114 assertions
Date: 5 days ago
Size: 5,075 bytes

 

You need to be a registered user and login to get this file.

Login Immediately with your account on: