(self, name, email, comment, passphrase=None)
Generate GPG Keys
Generate GPG Keys
Generate GPG Keys
def create_keys(self, name, email, comment, passphrase=None):
        """Generate GPG Keys"""

        # Check if there is already a key with this e-mail address
        matching_key = self._find_gpg_key_by_email(email)
        if (matching_key):
            logger.info("Found existing key {} with uid {}".format(
                matching_key['fingerprint'], matching_key['uids']))

            if (not self.interactive):
                logger.info("Aborting")
                return
            elif (util.ask_yes_or_no("Abort the creation of a new key?")):
                return

        # Password
        if (passphrase is None):
            self.prompt_passphrase('Please enter a passphrase to protect '
                                   'your key: ')
        else:
            self.set_passphrase(passphrase)

        # Generate key
        key_params = self.gpg.gen_key_input(key_type="RSA",
                                            key_length=1024,
                                            name_real=name,
                                            name_comment=comment,
                                            name_email=email,
                                            passphrase=self.passphrase)
        self.gpg.gen_key(key_params)
        logger.info("Keys succesfully generated at {}".format(
            os.path.abspath(self.gpghome)))
def create_keys ( self , name , email , comment , passphrase = None ) : # Check if there is already a key with this e-mail address matching_key = self . _find_gpg_key_by_email ( email ) if ( matching_key ) : logger . info ( "Found existing key {} with uid {}" . format ( matching_key [ 'fingerprint' ] , matching_key [ 'uids' ] ) ) if ( not self . interactive ) : logger . info ( "Aborting" ) return elif ( util . ask_yes_or_no ( "Abort the creation of a new key?" ) ) : return # Password if ( passphrase is None ) : self . prompt_passphrase ( 'Please enter a passphrase to protect ' 'your key: ' ) else : self . set_passphrase ( passphrase ) # Generate key key_params = self . gpg . gen_key_input ( key_type = "RSA" , key_length = 1024 , name_real = name , name_comment = comment , name_email = email , passphrase = self . passphrase ) self . gpg . gen_key ( key_params ) logger . info ( "Keys succesfully generated at {}" . format ( os . path . abspath ( self . gpghome ) ) )