password-analysis
Version:
A library for analyzing the strength of a password
8 lines (7 loc) • 426 B
text/typescript
export function getFeedback(entropy: number, common: boolean, patterns: string[]): string {
if (entropy < 28) return "Very weak: Add more characters.";
if (common) return "Weak: Avoid common passwords.";
if (patterns.length > 0) return `Weak: Avoid ${patterns.join(", ")} patterns.`;
if (entropy < 50) return "Moderate: Use a mix of letters, numbers, and symbols.";
return "Strong password!";
}