def METHOD_NAME(self, data, fingerprints, encode_base64):
    """
    encrypts data
    set encode_base64 to True to base64 encode data before writing
    """
    assert isinstance(fingerprints, list)
    _data = data
    self.encoding = "original"
    if encode_base64:
        _data = base64.b64encode(data.encode())
        self.encoding = "base64"
    enc = gpg_obj().encrypt(_data, fingerprints, sign=True, armor=False, **GPG_KWARGS)
    if enc.ok:
        self.data = enc.data
        self.recipients = [{"fingerprint": f} for f in fingerprints]
    else:
        raise GPGError(enc.status)