Skip to content

Commit 6156db7

Browse files
contributed Password breach checker
1 parent 52112f3 commit 6156db7

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# password breach checker
2+
## Description:
3+
- This program checks whether your password leaked in any Data Breaches.
4+
- Your can even do it at (https://haveibeenpwned.com/Passwords)
5+
- but Your password travels over internet right? so, its not safest method.
6+
- This works in most efficient way in your offline pc.
7+
- When You enter a password, it will be hashed with sha1
8+
- first 5 letters of hash code will be sent to haveibeenpwned API and receives a Dict of password Data with those first 5 characters of hashed password then this program crosscheck with the received hash and
9+
- finds whether your password leaked, if so how many times . else, it shows good to go.
10+
## Instructions:
11+
1) Download passwordbreach.py
12+
2) Open Terminal/CMD/Powershell
13+
3) Go to Directory of passwordbreach.py (downloads folder in general)
14+
4) Execute the below cmd
15+
5) ### ```python3 passwordbreach.py x y z``` ( x,y,z are your passwords. You can enter infinite)
16+
### Just ping me your doubts or to get collaborated on further projects!
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import requests
2+
import hashlib
3+
import sys
4+
5+
def request_api_data(qchar):
6+
url = 'https://api.pwnedpasswords.com/range/' + qchar
7+
res = requests.get(url)
8+
if res.status_code != 200:
9+
raise RuntimeError(f' Error fetching : {res.status_code},check the api and try again')
10+
return res
11+
12+
def get_password_leaks_count(hashes,h_to_check):
13+
hashes= (line.split(':')for line in hashes.text.splitlines())
14+
for h,count in hashes:
15+
if h == h_to_check:
16+
return count
17+
return 0
18+
19+
def hashing(password):
20+
sha1password = hashlib.sha1(password.encode('utf=8')).hexdigest().upper()
21+
f5char,l5char = sha1password[:5], sha1password[5:]
22+
response= request_api_data(f5char)
23+
return get_password_leaks_count(response,l5char)
24+
25+
def main(args):
26+
for password in args:
27+
count=hashing(password)
28+
if count:
29+
print(f'{password} was found {count} times... its high on time to change the password {password} to better secured !')
30+
else:
31+
print(f'{password} was NOT found. It seems Good to Go!')
32+
return 'done!'
33+
34+
if __name__=='__main__':
35+
sys.exit(main(sys.argv[1:]))
36+
37+

0 commit comments

Comments
 (0)