# Maskpass

Maskpass is a Python library like getpass but with advanced features like masking and reveal/unreveal.   
It also works in Spyder IDE

### Installation

Use the package manager [pip](https://pip.pypa.io/en/stable/) to install [maskpass](https://pypi.org/project/maskpass/).

```bash
pip install maskpass
```

### Usage
This module contains functions askpass() and advpass()  
askpass() uses msvcrt.getch() in windows and altenatives in *nix OS, but it doesn't work in Spyder. 

```python
import maskpass
password = maskpass.askpass()

```

The function returns the entered password in string format  
Accepts 2 optional arguments prompt and mask.  Default for prompt is `Enter password: `.  Default for mask is `*`.  
Use ` mask=""` for not echoing anything into the terminal. (Like entering sudo passwords in *nix)

### Using advpass()

advpass() uses [pynput](https://pypi.org/project/pynput/) to get the password, and it works in Spyder too!


```python
import maskpass
password = maskpass.advpass()
```
The function returns the entered password in string format.  
Accepts 3 optional arguments prompt, mask and ide.  Default for prompt is `Enter password: `. Default for mask is `*`.

ide expects a bool, it is for overriding IDE check, and has default False. Usually there is no need to change this, since it's automatically checked whether it's running on IDE or terminal.  

`advpass()` also has a revealing feature which will toggle the visibility of the entered password when `Left CTRL` is pressed.       Press it again to change back the visibility.  
Note: Only works with `advpass()` and needs [pynput](https://pypi.org/project/pynput/)

## Exceptions and other returns

In both askpass and advpass, pressing `Ctrl+C` raise the usual `KeyboardInterrupt`.  

Also, pressing `Escape` in both functions stops the input and returns an empty string `""`. 

### Screenshots

![Example GIF](https://raw.githubusercontent.com/FuturisticGoo/maskpass/main/images/example.gif)
>Normal askpass

![Spyder Example GIF](https://raw.githubusercontent.com/FuturisticGoo/maskpass/main/images/example2.gif)
>advpass in Spyder

![Terminal Example GIF](https://raw.githubusercontent.com/FuturisticGoo/maskpass/main/images/example3.gif)
>advpass in terminal

### Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

### Issues
Currently I have only tested it in Windows 10, Manjaro and Parrot, so I'm not sure it works in macOS.
`advpass()` works well in Spyder, Windows cmd/powershell/terminal and most of the Linux terminals.
Haven't tested it in PyCharm yet, so it might work.

### License
[MIT License](https://choosealicense.com/licenses/mit/)
