function pad4(str) {
    while (str.length < 4) {
        str = `0${str}`;
    }
    return str;
}
Adds leading zeros if shorter than four characters. Used for fixed-length hexadecimal values.

@private
@param {String} str
@returns {string}