def bytes_to_hex(b: bytes) -> str:
    """
    Implementation of the standard Python bytes.hex method, which is not available in
    Python 3.4.
    """
    try:
        return b.hex()
    except AttributeError:
        return "".join("{:0>2x}".format(c) for c in b)