pynentry


Namepynentry JSON
Version 0.1.7 PyPI version JSON
download
home_pagehttps://github.com/Laharah/pynentry
SummaryA pythonic wrapper around pinentry for secure password input
upload_time2024-08-12 18:36:11
maintainerNone
docs_urlNone
authorlaharah
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PynEntry
### A pythonic wrapper for pinentry

Written mostly to practice metaprogramming

credit to [mijikai](https://github.com/mijikai/pynentry) 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:
```python
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')
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Laharah/pynentry",
    "name": "pynentry",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "laharah",
    "author_email": "laharah22+pyn@gmail.com",
    "download_url": null,
    "platform": null,
    "description": "# PynEntry\n### A pythonic wrapper for pinentry\n\nWritten mostly to practice metaprogramming\n\ncredit to [mijikai](https://github.com/mijikai/pynentry) for a working example\n\n***Requires pinentry to be installed***\n\n#### convienience methods:\n\n* to quickly and simply get a password/pin from a user:\n\n`get_pin(description=None, prompt=None, timeout=0, display=None, global_grab=True)`\n\n* to show and get a confirmation from a user:\n\n`get_confirm(description=None, timeout=0, display=None, global_grab=True)`\n\n* to show a message to a user:\n\n`show_message(description=None, timeout=0, display=None, global_grab=True)`\n\n#### PynEntry class\nThe above methods instance and configure a PynEntry instance wich can be called and configured manually\nvia attributes\n\n\nthe PynEntry class supports the following attributes:\n\n* `description`: Sets the descriptive text to display\n* `prompt`: Sets the text just before the passphrase entry (ex: \"PASS:\")\n* `title`: Sets the window title\n* `ok_text`: Sets the text shown in the \"OK\" button\n* `cancel_text`: Sets the text shown in the \"Cancel\" button\n* `error_text`: Sets the text in case of error before reprompt (Cleared after every `get_pin()` call)\n* `tty_name`: Chose the tty to use (set automatically)\n* `tty_type`: Change the tty type to use.\n* `locale`: Sets the locale to use (set automatically to current os locale)\n\n***NOTE: The PynEntry class uses the $PATH variable to find the pinentry executable, you can specify the location of the\nexecutable manually when you initialize like so: `PynEntry(executable='/path/to/pinentry')`***\n\nPynEntry is best used as a context manager to automatically kill the pinentry process when you are done.\n\n#### Example:\n```python\nimport pynentry\npynentry.show_message('Hello there!')\n\nwith pynentry.PynEntry() as p:\n    p.description = 'Enter a password.\\n Choose Wisely!'\n    p.prompt = 'PASS>'\n    try:\n        passwd = p.get_pin()\n    except pynentry.PinEntryCancelled:\n        print('Cancelled?! Goodbye.')\n        exit()\n    p.ok_text = 'yep!'\n    p.cancel_text = 'nope!'\n    p.description = f'CAN YOU CONFIRM YOUR SUPER SECRET PASSWORD IS {passwd}?'\n    if p.get_confirm():\n            print(f'password {passwd} saved!')\n    else:\n            print(f'Too bad, so sad')\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A pythonic wrapper around pinentry for secure password input",
    "version": "0.1.7",
    "project_urls": {
        "Homepage": "https://github.com/Laharah/pynentry"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d5f0e2d1640edae8d21672b562b936001327ec875264b188e8cba305de239133",
                "md5": "f1639fc40ae85fc47f097585d712a546",
                "sha256": "62332b8cd922901f4c9dd7533e84d6f6fac4cc85a3d29fd6d0db49e27e507f21"
            },
            "downloads": -1,
            "filename": "pynentry-0.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f1639fc40ae85fc47f097585d712a546",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5319,
            "upload_time": "2024-08-12T18:36:11",
            "upload_time_iso_8601": "2024-08-12T18:36:11.087591Z",
            "url": "https://files.pythonhosted.org/packages/d5/f0/e2d1640edae8d21672b562b936001327ec875264b188e8cba305de239133/pynentry-0.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-12 18:36:11",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Laharah",
    "github_project": "pynentry",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pynentry"
}
        
Elapsed time: 0.45371s