Skip to main content

A flexible and easy to use, terminal based password input utility

Project description

GPass

GPass is a flexible and easy to use, terminal based password input utility

It is a variation of the stdiomask utility which allows users to securely input passwords onto the terminal.

However, many a times, piping, storing and redirection of the output often leads to the program not allowing the developer to safely input the password. This program was created to avert the same, along with create more types of possible masks for the passwords.

Installation

A PyPI installation can be achieved by

python3 -m pip install gpass 

A build from source can be done by

git clone https://gitlab.com/loggerheads-with-binary/gpass
cd gpass
python3 -m pip install -r requirements.txt 
python3 setup.py install

Using in your scripts

>>> import gpass

#Check below for meanings of colored and mask 
>>> var = gpass.getpass("Enter your password: " , colored = True , mask = gpass.SPECIAL_MASKS.MIMI_REVERSE)
Enter your password: ************
>>>var
'password1234' 

Masks

The following different masks can be used

  1. str : Any python string can be used as a mask

String Mask

  1. gpass.SPECIAL_MASKS.NO_MASK : Equivalent of having no mask, all characters are displayed directly. Can also be used with mask=False

No Mask

  1. gpass.SPECIAL_MASKS.BLIND_MASK : Does not echo any character. Equivalent of read -n on unix. Can also be used with mask=None or mask=''

Blind Mask

  1. gpass.SPECIAL_MASKS.DEFAULT_MASK : Uses the '*' character to mask every single input character. Can also be achieved by using '*' as the mask. Can also be used with mask=True

  2. gpass.SPECIAL_MASKS.ONE_REVERSE : Displays the last character of the input password in plaintext, and the rest of them in '*' characters, similar to some website password inputs.

  3. gpass.SPECIAL_MASKS.MIMI_REVERSE : Similar to ONE_REVERSE but also works backwards, i.e when characters are removed from the terminal.

One Reverse and Mimi Reverse

Colored Input

You can receive color input by using colored=True in the gpass.getpass function. Colors for prompt and input are also customizable with the colorset parameter, which can be a two-member list/tuple consisting of (prompt, input) colors.

Colored and Colorset

By default, the colorset = ('yellow' , 'green')
However, note that the colors must be defined. For example, magenta+cyan color does not exist and will raise a KeyError. The colors are as per those defined in termcolor

As a rule of thumb, only the following colors are allowed:

  • grey
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white

One could also use default, that being the default color of the terminal.

Use of stderr

The program uses the stderr stream to print the mask while uses the Getch function to take input characters. This allows the program to easily surpass any pipes or redirections in the terminal as long as the redirections/pipes involve stdout and not stderr.

No Interference while redirecting, storing or piping output

If you wish to instead use the stdout, or output the password to a filestream, change the stream parameter of the getpass function to sys.stdout or a filehandle.

License

The program uses the MIT License.

Bugs

Bugs can be raised in issues. For any improvements, please fork the project. If you feel your fork is better than this project and should be used as a substitute instead, mail me at dev@aniruddh.ml and I will set a pointer over at this project to yours.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gpass-2.1.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

gpass-2.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file gpass-2.1.0.tar.gz.

File metadata

  • Download URL: gpass-2.1.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for gpass-2.1.0.tar.gz
Algorithm Hash digest
SHA256 bbbcec3ca61b989ef3f12ab36c5d850abc5e5d12ea4d7e76e39881f420fbccf7
MD5 6504f3f47e8ccbe7d8ed455b5c1084e1
BLAKE2b-256 3d0ab22a1f58bf2839fd8ce6000de0371f37829f83a1b5f49564df25307e8961

See more details on using hashes here.

File details

Details for the file gpass-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: gpass-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for gpass-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68f320b495cce5b491ade8f16d719ea91a8de816c188f7117085a9cd9aecd640
MD5 7a3285e2cb698d6403286f247e43465b
BLAKE2b-256 ebc403cfde1518dc06f6ba0f753686e05b352f24e832991e94dad7d04b89a710

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page