🛡️ Pattern Detection

Advanced pattern detection to identify common weak password patterns and apply appropriate penalties.


Live Pattern Detection

Type a password to see real-time pattern detection in action.

Pattern Types
1. Sequential Characters (-15%)

Examples: abc, 123, xyz, 321

2. Repeated Characters (-10%)

Examples: aaa, 111, !!!

3. Keyboard Patterns (-20%)

Examples: qwerty, asdf, 12345

4. Common Substitutions (-10%)

Examples: p@ssw0rd, h3ll0

5. Date Patterns (-15%)

Examples: 2024, 01011990


Pattern Examples

Click on any example to test it.

❌ Weak Patterns
⚠️ Medium Patterns
✅ Strong (No Patterns)

Integration with PasswordMeter

Pattern detection is automatically enabled when Config.DetectPatterns = true.

Password Requirements:

    Configuration
    var config = new PasswordMeterConfig
    {
        DetectPatterns = true,
        CheckCommonPasswords = true,
        ScoringCurve = ScoringCurveType.Step
    };

    Technical Details

    The pattern detection algorithm performs a single-pass analysis with O(n) complexity:

    • Sequential: Compares consecutive characters for ascending/descending sequences
    • Repeated: Looks for 3+ identical consecutive characters
    • Keyboard: Matches against a predefined list of common keyboard patterns
    • Substitutions: Counts common leet-speak character replacements
    • Dates: Uses regex patterns to detect date formats

    Performance: Average detection time < 2ms

    Penalties are cumulative but capped at 50% maximum reduction:

    Pattern Type Penalty
    Sequential Characters-15%
    Repeated Characters-10%
    Keyboard Patterns-20%
    Common Substitutions-10%
    Date Patterns-15%
    Maximum Total-50%

    The penalty is applied as a percentage reduction to the base password score.

    using BlazorX.Components.PasswordMeter.Services;
    
    var patternService = new PatternDetectionService();
    var result = patternService.DetectPatterns("qwerty123");
    
    if (result.HasAnyPatterns)
    {
        Console.WriteLine($"Penalty: {result.PenaltyScore}%");
        
        foreach (var pattern in result.DetectedPatterns)
        {
            Console.WriteLine($"- {pattern}");
        }
    }
    
    // Output:
    // Penalty: 20%
    // - Keyboard pattern detected (e.g., qwerty, asdf)