cybersecurity · beginner · ~15 min

Base64 encoded length

Compute the padded base64 output size.

Challenge

Implement int base64_len(int n) returning the length of the base64 encoding of n input bytes: 4 * ceil(n / 3) = 4 * ((n + 2) / 3).

Starter code

int base64_len(int n) {
    /* TODO */
    return 0;
}

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