cybersecurity · beginner · ~15 min

Detect weak crypto algorithm names

Case-insensitive substring scan; per-line iteration.

Challenge

Given a config string, count how many lines mention any of these known-weak ciphers (case-insensitive substring match): MD5, SHA1, DES, RC4, 3DES. Implement int weak_crypto_count(const char *config).

Why this matters

Auditing config files for deprecated crypto is the kind of grep-able problem real security tools (semgrep, bandit, OpenSSL hardener) solve every day. Implementing one teaches the alert-vs-allow distinction.

Input format

Multi-line config buffer, null-terminated.

Output format

Number of lines containing any weak algorithm.

Constraints

Each line counts at most once even if it mentions several.

Starter code

int weak_crypto_count(const char *config) { /* TODO */ return 0; }

Common mistakes

Counting SHA256 as SHA1 (need word boundary or proper token check — for this exercise substring is fine, but watch the test cases); counting the same line twice when two algorithms appear.

Edge cases to handle

Empty input. Line with two weak ciphers — counts once.

Complexity

O(n * weak_count).

Background lessons

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.