@@ -17,7 +17,7 @@ type ValidationResult struct {
1717// Following NIST and OWASP best practices:
1818// - Minimum 12 characters (stronger than previous 8)
1919// - At least 1 uppercase letter
20- // - At least 1 lowercase letter
20+ // - At least 1 lowercase letter
2121// - At least 1 digit
2222// - At least 1 special character
2323func Validate (passphrase string ) ValidationResult {
@@ -35,7 +35,7 @@ func Validate(passphrase string) ValidationResult {
3535
3636 // Character set requirements
3737 hasUpper , hasLower , hasDigit , hasSpecial := false , false , false , false
38-
38+
3939 for _ , char := range passphrase {
4040 switch {
4141 case unicode .IsUpper (char ):
@@ -74,11 +74,11 @@ func GetErrorMessage(result ValidationResult) string {
7474 if result .Valid {
7575 return ""
7676 }
77-
77+
7878 if len (result .Errors ) == 1 {
7979 return result .Errors [0 ]
8080 }
81-
81+
8282 return fmt .Sprintf ("Passphrase requirements not met:\n • %s" , strings .Join (result .Errors , "\n • " ))
8383}
8484
@@ -87,16 +87,16 @@ func GetStrength(passphrase string) string {
8787 if len (passphrase ) < 8 {
8888 return "Very Weak"
8989 }
90-
90+
9191 result := Validate (passphrase )
9292 if ! result .Valid {
9393 return "Weak"
9494 }
95-
95+
9696 // Count character types
9797 types := 0
9898 hasUpper , hasLower , hasDigit , hasSpecial := false , false , false , false
99-
99+
100100 for _ , char := range passphrase {
101101 if unicode .IsUpper (char ) && ! hasUpper {
102102 hasUpper = true
@@ -115,7 +115,7 @@ func GetStrength(passphrase string) string {
115115 types ++
116116 }
117117 }
118-
118+
119119 // Simple strength scoring based on length and character diversity
120120 if len (passphrase ) >= 16 && types == 4 {
121121 return "Strong"
@@ -124,4 +124,4 @@ func GetStrength(passphrase string) string {
124124 } else {
125125 return "Weak"
126126 }
127- }
127+ }
0 commit comments