readchar-readpass 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""getpassword package.
|
|
2
|
+
|
|
3
|
+
This package exposes a simple helper for obtaining a password from the
|
|
4
|
+
user without echoing it to the terminal. It instead echos a '*' character for each character typed, and allows the user to use backspace to correct mistakes.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from getpassword import getpass
|
|
8
|
+
|
|
9
|
+
__all__ = ["get_password", "__version__"]
|
|
10
|
+
__version__ = "0.1.0"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def get_password(prompt: str = "Password: ") -> str:
|
|
14
|
+
"""Read a password from stdin without echoing it.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
prompt: The prompt text shown to the user.
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
The entered password string.
|
|
21
|
+
"""
|
|
22
|
+
return getpass(prompt)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import readchar
|
|
2
|
+
|
|
3
|
+
def getpass():
|
|
4
|
+
password = ""
|
|
5
|
+
while True:
|
|
6
|
+
char = readchar.readchar()
|
|
7
|
+
if char == '\r':
|
|
8
|
+
break
|
|
9
|
+
elif char == '\b':
|
|
10
|
+
password = password[:-1]
|
|
11
|
+
print('\b \b', end='', flush=True)
|
|
12
|
+
else:
|
|
13
|
+
password += char
|
|
14
|
+
print('*', end='', flush=True)
|
|
15
|
+
return password
|
|
16
|
+
|
|
17
|
+
if __name__ == "__main__":
|
|
18
|
+
print("Enter your password: ", end='', flush=True)
|
|
19
|
+
password = getpass()
|
|
20
|
+
print("\nYour password is:", password)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: readchar-readpass
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A password reader.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Uchihashuraim/getpassword
|
|
6
|
+
Author-email: Shuraim Ibrahim Khan <Uchihashuraim@gmail.com>
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Requires-Dist: readchar>=4.2.0
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
|
|
15
|
+
# getpassword
|
|
16
|
+
|
|
17
|
+
A small Python utility for reading masked password input from the terminal.
|
|
18
|
+
|
|
19
|
+
This project provides a simple `get_password()` helper that accepts user input one character at a time, prints `*` for each keystroke, and supports backspace editing.
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- Reads a password from the terminal without showing the raw characters
|
|
24
|
+
- Displays `*` for each character typed
|
|
25
|
+
- Supports backspace to correct mistakes
|
|
26
|
+
- Minimal dependency footprint
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
This project includes packaging metadata in `pyproject.toml`, so it can be installed with:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install getpassword
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
For local development from the repository, install in editable mode:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
python -m pip install -e .
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
If you prefer a normal local install:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
python -m pip install .
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The package dependency `readchar` will be installed automatically.
|
|
49
|
+
|
|
50
|
+
## Usage
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from getpassword import get_password
|
|
54
|
+
|
|
55
|
+
password = get_password("Password: ")
|
|
56
|
+
print("You entered", password)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
You can also run the script directly from the repository:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
python src/getpassword/getpassword.py
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Project structure
|
|
66
|
+
|
|
67
|
+
- `src/getpassword/getpassword.py` - core password input implementation
|
|
68
|
+
- `src/getpassword/__init__.py` - package entrypoint exposing `get_password`
|
|
69
|
+
|
|
70
|
+
## Dependency
|
|
71
|
+
|
|
72
|
+
- `readchar`
|
|
73
|
+
|
|
74
|
+
## Notes
|
|
75
|
+
|
|
76
|
+
This package is intended for simple console-based password entry. It does not provide advanced terminal handling or cross-platform terminal abstraction beyond the `readchar` dependency.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
readchar_readpass/__init__.py,sha256=1rOm9C6TByZr30cjJlduRtRO4m941egfO9p7sUGv6vg,635
|
|
2
|
+
readchar_readpass/getpassword.py,sha256=R8QrGOiul7Qu9Yn_o8k2kxrhd5p_EN0VZoJmZZwiYko,531
|
|
3
|
+
readchar_readpass-0.1.0.dist-info/METADATA,sha256=Xgr9XEEkxzf998LBUEP_WV6LlDO5Ys77DjH43iKT8Qw,1978
|
|
4
|
+
readchar_readpass-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
5
|
+
readchar_readpass-0.1.0.dist-info/licenses/LICENSE,sha256=AZRYTe5bvNqYunBjfMxVpYTWc5QPHqvyUMQRmgya7lU,1096
|
|
6
|
+
readchar_readpass-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Shuraim Ibrahim Khan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|