Skip to main content

PynEntry

A pythonic wrapper for pinentry

Written mostly to practice metaprogramming

credit to mijikai for a working example

Requires pinentry to be installed

convienience methods:

  • to quickly and simply get a password/pin from a user:

get_pin(description=None, prompt=None, timeout=0, display=None, global_grab=True)

  • to show and get a confirmation from a user:

get_confirm(description=None, timeout=0, display=None, global_grab=True)

  • to show a message to a user:

show_message(description=None, timeout=0, display=None, global_grab=True)

PynEntry class

The above methods instance and configure a PynEntry instance wich can be called and configured manually via attributes

the PynEntry class supports the following attributes:

  • description: Sets the descriptive text to display
  • prompt: Sets the text just before the passphrase entry (ex: "PASS:")
  • title: Sets the window title
  • ok_text: Sets the text shown in the "OK" button
  • cancel_text: Sets the text shown in the "Cancel" button
  • error_text: Sets the text in case of error before reprompt (Cleared after every get_pin() call)
  • tty_name: Chose the tty to use (set automatically)
  • tty_type: Change the tty type to use.
  • locale: Sets the locale to use (set automatically to current os locale)

NOTE: The PynEntry class uses the $PATH variable to find the pinentry executable, you can specify the location of the executable manually when you initialize like so: PynEntry(executable='/path/to/pinentry')

PynEntry is best used as a context manager to automatically kill the pinentry process when you are done.

Example:

import pynentry
pynentry.show_message('Hello there!')

with pynentry.PynEntry() as p:
    p.description = 'Enter a password.\n Choose Wisely!'
    p.prompt = 'PASS>'
    try:
        passwd = p.get_pin()
    except pynentry.PinEntryCancelled:
        print('Cancelled?! Goodbye.')
        exit()
    p.ok_text = 'yep!'
    p.cancel_text = 'nope!'
    p.description = f'CAN YOU CONFIRM YOUR SUPER SECRET PASSWORD IS {passwd}?'
    if p.get_confirm():
            print(f'password {passwd} saved!')
    else:
            print(f'Too bad, so sad')

Release files for pynentry 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pynentry 0.1.1
File Size Uploaded
pynentry-0.1.1.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pynentry 0.1.1
File Interpreter ABI Platform
pynentry-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 9.3 kB

Release files / pynentry-0.1.1.tar.gz

Download URL pynentry-0.1.1.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
da3e8413ba063d940e55e7d430cae2c30cd345d369f605e00cb99801740abe75
BLAKE2b-256 checksum
How to use checksums
2619ed4e3e29cb2d82af10e4befc9ed992a92305900a725064d3294f0206ed86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.4

Release files / pynentry-0.1.1-py3-none-any.whl

Download URL pynentry-0.1.1-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f703b8b2b41e7bb092fb681d77beaa2dd79e65c6b0f26898a4113c951ae1d60
BLAKE2b-256 checksum
How to use checksums
66504862b90fdd977910ce4c5e210f9b70eb2227d503e962f83982c3f20582da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.4

Release history Release notifications | RSS feed

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page