首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Python GnuPG密钥生成不起作用

Python GnuPG密钥生成不起作用
EN

Stack Overflow用户
提问于 2015-11-22 21:44:04
回答 1查看 144关注 0票数 1

我在使用Python-GnuGP lib的GPG密钥生成程序员中工作(只是为了让我的生活更轻松)。我为UI和获取值使用了PyQt,并使用了两个类(一个用于主up,另一个用于对话框)来生成我的键。问题是,当我执行GenButton时,我在终端中得到以下错误:

代码语言:javascript
复制
Key-Type: RSA
Key-Length: 4096
Passphrase: 1202
Name-Real: TestUser
Name-Email: test@gmail.com
Expire-Date: 2019-3-3
%commit

key not created

下面是我的代码:我使用内置的值对其进行了测试,一切工作正常,但是当我从QlineEdit框传递值时,我得到了上面的错误。

代码语言:javascript
复制
class GenKeyDialog(QtGui.QDialog, Ui_GPGGenerateWindow):
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        self.setupUi(self)
        self.gpg = gnupg.GPG(homedir='keys')
        self.gpg.encoding = 'utf-8'

        self.GenButton.clicked.connect(self.genkey)

    def genkey(self):
        type = "RSA"
        length = 4096
        name = str(self.NameEdit.text())
        email = str(self.EmailEdit.text())
        if str(self.PassEdit.text()) == str(self.RPassEdit.text()):
            passs = str(self.PassEdit.text())
        else:
            print "passwords do not match"
            return

        expire = str(self.ExpireEdit.text())
        input_data = self.gpg.gen_key_input(key_type=type, key_length=length, name_real=name, name_email=email, passphrase=passs, expire_date=expire)
        print input_data
        key = self.gpg.gen_key(input_data)
        print key


class Main_window_ex(QMainWindow, Ui_MainWindow):
    def createPGP(self):
        dialog = GenKeyDialog()
        ret = dialog.exec_()


    def __init__(self, parent = None):
        """
        Default Constructor. It can receive a top window as parent. 
        """

截图:

EN

回答 1

Stack Overflow用户

发布于 2016-10-28 16:18:06

您正在将Main_window_ex.__init__实现为一个空函数。当该类的实例被初始化时,不会发生任何事情。

我怀疑您想要的是让Main_window_ex实例完全像它的父类一样初始化。如果这是您想要的,就不要实现特定的Main_window_ex.__init__

您在学习the Python tutorial时就已经了解到了这一点,特别是它关于classes and inheritance的章节。希望这是一个提醒:-)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33855429

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档