def _pad(data):
    """Pad the data to encrypt to be a multiple of 16."""
    # return data if no padding is required
    if len(data) % 16 == 0:
        return data

    # subtract one byte that should be the 0x80
    # if 0 bytes of padding are required, it means only
    # a single \x80 is required.
    padding_required = 15 - (len(data) % 16)
    data = "%s\x80" % data
    data = "%s%s" % (data, "\x00" * padding_required)
    return data