cybersecurity · intermediate · ~15 min · safe pentest lab

UID bytes to hex

Hex-encode a byte buffer.

Challenge

Implement int uid_to_hex(const unsigned char *uid, int n, char *out, int outsz) writing the lowercase hex of n bytes into out, returning the length (n2), or -1 if it won't fit (need n2+1 bytes).

Starter code

int uid_to_hex(const unsigned char *uid, int n, char *out, int outsz) {
    /* TODO */
    return -1;
}

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