Untitled

 avatar
unknown
plain_text
5 months ago
977 B
5
Indexable
#include <cstring>
#include <cctype>

extern "C" {
    const char* check_password_strength(const char* password) {
        int length = strlen(password);
        bool has_upper = false, has_lower = false, has_digit = false, has_special = false;

        for (int i = 0; i < length; i++) {
            if (isupper(password[i])) has_upper = true;
            else if (islower(password[i])) has_lower = true;
            else if (isdigit(password[i])) has_digit = true;
            else has_special = true;
        }

        if (length < 8) return "Weak: Minimum 8 characters required.";
        if (!has_upper) return "Weak: At least one uppercase letter required.";
        if (!has_lower) return "Weak: At least one lowercase letter required.";
        if (!has_digit) return "Weak: At least one digit required.";
        if (!has_special) return "Weak: At least one special character required.";

        return "Strong: Password is strong.";
    }
}
Editor is loading...
Leave a Comment