How to use the pyotp.totp.TOTP function in pyotp

To help you get started, we’ve selected a few pyotp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Truth0906 / PTTOTP / PTTOTP / systemtray.py View on Github external
self.console.config.load()
        if self.console.config.get(config.key_otp_key) is None:

            self.system_alert(f'{self.console.ptt_id} 歡迎使用 Ptt OTP')
            rule_form = rule_window.Form(self.console)
            rule_form.show()
            rule_form.exec_()

            if not rule_form.ok:
                self.system_alert('Ptt OTP 感謝您的試用')
                time.sleep(3)
                self.exit_func()

            otp_key = pyotp.random_base32()

            otp_url = pyotp.totp.TOTP(otp_key).provisioning_uri(self.console.ptt_id, issuer_name="Ptt OTP")
            img = qrcode.make(otp_url)
            img.save('./temp.png')

            show_verify_form = show_verify.Form(self.console, otp_key)
            show_verify_form.show()
            show_verify_form.exec_()

            os.remove('./temp.png')

            if not show_verify_form.ok:
                self.system_alert('Ptt OTP 感謝您的試用')
                time.sleep(3)
                self.exit_func()

            self.console.config.set(config.key_otp_key, otp_key)

pyotp

Python One Time Password Library

MIT
Latest version published 1 year ago

Package Health Score

84 / 100
Full package analysis