Skip to content

This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.

Create generate_check_password.py

Abdul Wahab Junaidf9d657dcbb9f
diff --git a/Python Tools/Hashlib/generate_check_password.py b/Python Tools/Hashlib/generate_check_password.py
new file mode 100644
index 0000000..fb42963
--- /dev/null
+++ b/Python Tools/Hashlib/generate_check_password.py
@@ -0,0 +1,21 @@
+import uuid
+import hashlib
+
+def hash_password(password):
+ # uuid is used to generate a random number
+ salt = uuid.uuid4().hex
+ return hashlib.sha256(salt.encode() + password.encode()).hexdigest() + ':' + salt
+
+def check_password(hashed_password, user_password):
+ password, salt = hashed_password.split(':')
+ return password == hashlib.sha256(salt.encode() + user_password.encode()).hexdigest()
+
+new_pass = input('Enter your password: ')
+hashed_password = hash_password(new_pass)
+
+print('The password hash: ' + hashed_password)
+old_pass = input('Enter again the password for checking: ')
+if check_password(hashed_password, old_pass):
+ print("Password is correct")
+else:
+ print("Passwords doesn't match")