Skip to content

Commit 00dd1c0

Browse files
Merge pull request #989 from Developer-R-7/main
issue #937 (Are You Pawned) added
2 parents 004cbe6 + 26746a5 commit 00dd1c0

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed
37.5 KB
Loading
30 KB
Loading
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Are You Pawned!
2+
3+
## Aim
4+
A user can check there password pawned or not and how many times it pawned. This python script uses "**haveibeenpwned API V3**"
5+
6+
## Installation
7+
8+
No packages or modules to be install :)
9+
10+
## Setup Instructions
11+
12+
1. Have Python 3.x setup in the system
13+
2. Run the code using the command
14+
15+
```
16+
python are_you_pawned.py
17+
```
18+
and obtain the Output
19+
20+
## Source
21+
### [API Documentation](https://haveibeenpwned.com/API/v3)
22+
#### Example API request :
23+
`https://api.pwnedpasswords.com/range/{first 5 hash chars}`
24+
25+
Your password is converted to hash SHA-1 and only first 5 character of hash are send as params
26+
## Workflow of the Program
27+
1. The python script will be asking user to input the password
28+
2. While typing the script will not show the character it will just masked the password character
29+
3. After typing password ,press enter and obtain the output.
30+
31+
**program asking for input**
32+
```bash
33+
Password:
34+
```
35+
**if your password is pwned! this output will be shown**
36+
```bash
37+
Oh No - pwned! This Password has been seen 4 times before
38+
```
39+
**Not pwned!**
40+
```bash
41+
Good news — no pwnage found!
42+
```
43+
## Disclaimer
44+
This password wasn't found in any of the Pwned Passwords loaded into "**haveibeenpwned Datasets**". That doesn't necessarily mean it's a good password, merely that it's not indexed in the database of "**haveibeenpwned**".All data is fetch from the API through GET request.
45+
## Author
46+
Rushi Patel :)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import hashlib
2+
import getpass
3+
import requests
4+
5+
#Get Masked User Password
6+
#password = getpass.getpass()
7+
8+
#Uncomment this to not masked the password
9+
password = input('Password:')
10+
11+
#Making Password text into Hash SHA-1
12+
HASH_SHA1 = hashlib.sha1(str(password).encode('utf-8'))
13+
hash = HASH_SHA1.hexdigest()
14+
15+
#Making a request
16+
URL = "https://api.pwnedpasswords.com/range/{}".format(hash[0:5])
17+
r = requests.get(url=URL)
18+
data = list(str(r.text).split('\n'))
19+
20+
#We can modify this to better Searching alogrithms
21+
bool_pwned = False
22+
for i in data:
23+
tranform_data = str(i).replace("\r","").split(":")
24+
if hash.upper()[5::] == tranform_data[0]:
25+
bool_pwned = True
26+
break
27+
28+
if bool_pwned:
29+
print("\nOh No - pwned! This Password has been seen {} times before\n".format(tranform_data[1]))
30+
else:
31+
print("\nGood news — no pwnage found!\n")
32+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(1) hashlib
2+
(2) requests
3+
(3) getpass

0 commit comments

Comments
 (0)