From 2c6fa01242f3d92c779a29b4b1130d8417ee478c Mon Sep 17 00:00:00 2001 From: Gaurav451 <69210537+Gaurav451@users.noreply.github.com> Date: Sat, 22 Aug 2020 12:57:00 +0530 Subject: [PATCH 1/7] Create Password checker --- Basic-Scripts/Password checker | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Basic-Scripts/Password checker diff --git a/Basic-Scripts/Password checker b/Basic-Scripts/Password checker new file mode 100644 index 00000000..c95723e8 --- /dev/null +++ b/Basic-Scripts/Password checker @@ -0,0 +1,35 @@ +import requests +import hashlib +import sys + +def request_api_data(query_char): + url = 'https://api.pwnedpasswords.com/range/' + query_char + res = requests.get(url) + if res.status_code != 200: + raise RuntimeError(f': {res.status_code}, got some eror,please check API') + return res + +def get_password_leaks_count(hashes, hash_to_check): + hashes = (line.split(':') for line in hashes.text.splitlines()) + for h, count in hashes: + if h == hash_to_check: + return count + return 0 + +def pwned_api_check(password): + sha1password = hashlib.sha1(password.encode('utf-8')).hexdigest().upper() + first5_char, tail = sha1password[:5], sha1password[5:] + response = request_api_data(first5_char) + return get_password_leaks_count(response, tail) + +def main(args): + for password in args: + count = pwned_api_check(password) + if count: + print(f'{password} was found {count} times... you should change your password right now!') + else: + print(f'{password} was not found,very good password.') + return 'done!' + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) From f0ca46d11fb3ad5be6fc66b654fcd815431b8a3a Mon Sep 17 00:00:00 2001 From: Gaurav451 <69210537+Gaurav451@users.noreply.github.com> Date: Mon, 24 Aug 2020 12:12:11 +0530 Subject: [PATCH 2/7] Delete Password checker --- Basic-Scripts/Password checker | 35 ---------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 Basic-Scripts/Password checker diff --git a/Basic-Scripts/Password checker b/Basic-Scripts/Password checker deleted file mode 100644 index c95723e8..00000000 --- a/Basic-Scripts/Password checker +++ /dev/null @@ -1,35 +0,0 @@ -import requests -import hashlib -import sys - -def request_api_data(query_char): - url = 'https://api.pwnedpasswords.com/range/' + query_char - res = requests.get(url) - if res.status_code != 200: - raise RuntimeError(f': {res.status_code}, got some eror,please check API') - return res - -def get_password_leaks_count(hashes, hash_to_check): - hashes = (line.split(':') for line in hashes.text.splitlines()) - for h, count in hashes: - if h == hash_to_check: - return count - return 0 - -def pwned_api_check(password): - sha1password = hashlib.sha1(password.encode('utf-8')).hexdigest().upper() - first5_char, tail = sha1password[:5], sha1password[5:] - response = request_api_data(first5_char) - return get_password_leaks_count(response, tail) - -def main(args): - for password in args: - count = pwned_api_check(password) - if count: - print(f'{password} was found {count} times... you should change your password right now!') - else: - print(f'{password} was not found,very good password.') - return 'done!' - -if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) From b91b9d67d05466a09b56d555556e1685b667c9c3 Mon Sep 17 00:00:00 2001 From: Gaurav451 <69210537+Gaurav451@users.noreply.github.com> Date: Mon, 24 Aug 2020 12:12:50 +0530 Subject: [PATCH 3/7] Add files via upload --- Basic-Scripts/Password Checker.py | 35 +++++++++++++++++++++++++++++++ Basic-Scripts/README.md | 17 +++++++-------- 2 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 Basic-Scripts/Password Checker.py diff --git a/Basic-Scripts/Password Checker.py b/Basic-Scripts/Password Checker.py new file mode 100644 index 00000000..d69dbce9 --- /dev/null +++ b/Basic-Scripts/Password Checker.py @@ -0,0 +1,35 @@ +import requests +import hashlib +import sys + +def request_api_data(query_char): + url = 'https://api.pwnedpasswords.com/range/' + query_char + res = requests.get(url) + if res.status_code != 200: + raise RuntimeError(f': {res.status_code}, got some eror,please check API') + return res + +def get_password_leaks_count(hashes, hash_to_check): + hashes = (line.split(':') for line in hashes.text.splitlines()) + for h, count in hashes: + if h == hash_to_check: + return count + return 0 + +def pwned_api_check(password): + sha1password = hashlib.sha1(password.encode('utf-8')).hexdigest().upper() + first5_char, tail = sha1password[:5], sha1password[5:] + response = request_api_data(first5_char) + return get_password_leaks_count(response, tail) + +def main(args): + for password in args: + count = pwned_api_check(password) + if count: + print(f'{password} was found {count} times... you should change your password right now!') + else: + print(f'{password} was not found,very good password.') + return 'done!' + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:])) diff --git a/Basic-Scripts/README.md b/Basic-Scripts/README.md index 6376302b..51733797 100644 --- a/Basic-Scripts/README.md +++ b/Basic-Scripts/README.md @@ -1,10 +1,7 @@ -# Basic-Scripts -Basic-Scripts is a collection of basic python scripts for newbies in python to understand basic concept of python programming. -- Data Struture in python -- Conditional -- Loop -- Exception Handling -- Algorithms -- OOP -- Class -- Object \ No newline at end of file +# Password-checker + +#This program can help us to find how many times a password has been used,either on anonymous or your own used sites. + +#It will take help of requests,hashlib and sys modules + +#You need to install pip3 into your machine to be able to use this code. From 7b2ac8a5f05994606c227ec2513f56b5bc40a0c2 Mon Sep 17 00:00:00 2001 From: Gaurav451 <69210537+Gaurav451@users.noreply.github.com> Date: Mon, 24 Aug 2020 12:58:52 +0530 Subject: [PATCH 4/7] Rename Password Checker.py to password_checker.py --- Basic-Scripts/{Password Checker.py => password_checker.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Basic-Scripts/{Password Checker.py => password_checker.py} (100%) diff --git a/Basic-Scripts/Password Checker.py b/Basic-Scripts/password_checker.py similarity index 100% rename from Basic-Scripts/Password Checker.py rename to Basic-Scripts/password_checker.py From 4dc1304668ac436542c9f9becd83298c03bd8081 Mon Sep 17 00:00:00 2001 From: Gaurav451 <69210537+Gaurav451@users.noreply.github.com> Date: Mon, 24 Aug 2020 13:12:12 +0530 Subject: [PATCH 5/7] Update README.md --- Basic-Scripts/README.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Basic-Scripts/README.md b/Basic-Scripts/README.md index 51733797..84d508f8 100644 --- a/Basic-Scripts/README.md +++ b/Basic-Scripts/README.md @@ -1,7 +1,19 @@ -# Password-checker + #Basic-Scripts + Basic-Scripts is a collection of basic python scripts for newbies in python to understand basic concept of python programming. + -Data Structure in python + -Conditional + -Loop + -Exception handling + -Algorithms + -OOP + -Class + -Object + + + # Password-checker -#This program can help us to find how many times a password has been used,either on anonymous or your own used sites. + #This program can help us to find how many times a password has been used,either on anonymous or your own used sites. -#It will take help of requests,hashlib and sys modules + #It will take help of requests,hashlib and sys modules -#You need to install pip3 into your machine to be able to use this code. + #You need to install pip3 into your machine to be able to use this code. From fc817a4eed4be9c334910059d566b062c3531eeb Mon Sep 17 00:00:00 2001 From: Gaurav451 <69210537+Gaurav451@users.noreply.github.com> Date: Mon, 24 Aug 2020 17:47:59 +0530 Subject: [PATCH 6/7] Update README.md --- Basic-Scripts/README.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Basic-Scripts/README.md b/Basic-Scripts/README.md index 84d508f8..702ab86b 100644 --- a/Basic-Scripts/README.md +++ b/Basic-Scripts/README.md @@ -10,10 +10,4 @@ -Object - # Password-checker - - #This program can help us to find how many times a password has been used,either on anonymous or your own used sites. - - #It will take help of requests,hashlib and sys modules - - #You need to install pip3 into your machine to be able to use this code. + From ab69c89fdc150a386a08317416d6533267dac308 Mon Sep 17 00:00:00 2001 From: Gaurav451 <69210537+Gaurav451@users.noreply.github.com> Date: Mon, 24 Aug 2020 17:48:35 +0530 Subject: [PATCH 7/7] Update password_checker.py --- Basic-Scripts/password_checker.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Basic-Scripts/password_checker.py b/Basic-Scripts/password_checker.py index d69dbce9..c381b34d 100644 --- a/Basic-Scripts/password_checker.py +++ b/Basic-Scripts/password_checker.py @@ -1,3 +1,13 @@ + # Password-checker + + #This program can help us to find how many times a password has been used,either on anonymous or your own used sites. + + #It will take help of requests,hashlib and sys modules + + #You need to install pip3 into your machine to be able to use this code. + + + import requests import hashlib import sys