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=Noneormask=''
-
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_REVERSEbut 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.
Release files for gpass 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gpass-2.1.0.tar.gz | 5.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gpass-2.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.4 kB
Release files / gpass-2.1.0.tar.gz
| Download URL | gpass-2.1.0.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bbbcec3ca61b989ef3f12ab36c5d850abc5e5d12ea4d7e76e39881f420fbccf7
|
|
BLAKE2b-256 checksum How to use checksums |
3d0ab22a1f58bf2839fd8ce6000de0371f37829f83a1b5f49564df25307e8961
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.7
|
Release files / gpass-2.1.0-py3-none-any.whl
| Download URL | gpass-2.1.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
68f320b495cce5b491ade8f16d719ea91a8de816c188f7117085a9cd9aecd640
|
|
BLAKE2b-256 checksum How to use checksums |
ebc403cfde1518dc06f6ba0f753686e05b352f24e832991e94dad7d04b89a710
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.7
|