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
str
: Any python string can be used as a mask
gpass.SPECIAL_MASKS.NO_MASK
: Equivalent of having no mask, all characters are displayed directly. Can also be used withmask=False
gpass.SPECIAL_MASKS.BLIND_MASK
: Does not echo any character. Equivalent of read -n on unix. Can also be used withmask=None
ormask=''
-
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 withmask=True
-
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. -
gpass.SPECIAL_MASKS.MIMI_REVERSE
: Similar toONE_REVERSE
but also works backwards, i.e when characters are removed from the terminal.
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.
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.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbbcec3ca61b989ef3f12ab36c5d850abc5e5d12ea4d7e76e39881f420fbccf7 |
|
MD5 | 6504f3f47e8ccbe7d8ed455b5c1084e1 |
|
BLAKE2b-256 | 3d0ab22a1f58bf2839fd8ce6000de0371f37829f83a1b5f49564df25307e8961 |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68f320b495cce5b491ade8f16d719ea91a8de816c188f7117085a9cd9aecd640 |
|
MD5 | 7a3285e2cb698d6403286f247e43465b |
|
BLAKE2b-256 | ebc403cfde1518dc06f6ba0f753686e05b352f24e832991e94dad7d04b89a710 |