(self, gpg, recipient, sign, trust)
Encrypt the data

        If encapsulated data is available, encrypt that. Otherwise, encrypt the
        original data.

        Args:
            gpg        : Gpg object.
            recipient  : Public key fingerprint of the desired recipient.
            sign       : GPG sign parameter: True to sign with the default key,
                         False to skip signing, or a fingerprint with the key
                         to use for signing.
            trust      : Skip key validation.
Encrypt the data
Encrypt the data
def encrypt(self, gpg, recipient, sign, trust):
        """Encrypt the data

        If encapsulated data is available, encrypt that. Otherwise, encrypt the
        original data.

        Args:
            gpg        : Gpg object.
            recipient  : Public key fingerprint of the desired recipient.
            sign       : GPG sign parameter: True to sign with the default key,
                         False to skip signing, or a fingerprint with the key
                         to use for signing.
            trust      : Skip key validation.


        """
        data = self.data['encapsulated'] if self.data['encapsulated'] \
            else self.data['original']

        logger.debug("Encrypt for recipient %s" % (recipient))

        if (sign and sign is not True):
            logger.debug("Sign message using key %s" % (sign))

        encrypted_obj = gpg.encrypt(data,
                                    recipient,
                                    always_trust=trust,
                                    sign=sign)
        if (not encrypted_obj.ok):
            logger.error(encrypted_obj.stderr)
            raise ValueError(encrypted_obj.status)

        self.data['encrypted'] = encrypted_obj.data
        logger.debug("Encrypted version of the data structure has %d bytes" %
                     (len(self.data['encrypted'])))
def encrypt ( self , gpg , recipient , sign , trust ) : data = self . data [ 'encapsulated' ] if self . data [ 'encapsulated' ] else self . data [ 'original' ] logger . debug ( "Encrypt for recipient %s" % ( recipient ) ) if ( sign and sign is not True ) : logger . debug ( "Sign message using key %s" % ( sign ) ) encrypted_obj = gpg . encrypt ( data , recipient , always_trust = trust , sign = sign ) if ( not encrypted_obj . ok ) : logger . error ( encrypted_obj . stderr ) raise ValueError ( encrypted_obj . status ) self . data [ 'encrypted' ] = encrypted_obj . data logger . debug ( "Encrypted version of the data structure has %d bytes" % ( len ( self . data [ 'encrypted' ] ) ) )