def replace_at_offset(hdr,offset,replace=None):
    """ Replace bytes at offset,  either with replacement bytes or given number of zero bytes """
    if (type(replace) is int):
        replace = b"\x00"*replace
    assert type(replace) is bytes, "Wrong input type"
    assert len(hdr) >= offset, "Offset to large"
    new_hdr = bytearray(hdr)
    for pos,octet in enumerate(replace):
        new_hdr[offset + pos] = octet
    return bytes(new_hdr)