Skip to content

Instantly share code, notes, and snippets.

@chankruze
Created October 28, 2018 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chankruze/51cba66e6898611bc4a976f97c576f08 to your computer and use it in GitHub Desktop.
Save chankruze/51cba66e6898611bc4a976f97c576f08 to your computer and use it in GitHub Desktop.
A simple hased password check script to demonstrate how servers check password when we enter it during log in.
import hashlib
print("# This is a demo on how servers checks your password when you enter it during login\n")
pass_in0 = input(">> Enter Your Demo Password\n")
hash_generate = hashlib.sha1(pass_in0.encode())
hex_gen0 = hash_generate.hexdigest()
print(">> Your Stored Hash is: "+ str(hex_gen0))
print("# This is stored in server when you signup for first time")
pass_in1 = input("\n>> Enter Demo Password Again To Varify\n")
hash_check = hashlib.sha1(pass_in1.encode())
hex_gen1 = hash_check.hexdigest()
print(">> Your Calculated Hash is: "+ str(hex_gen1))
print("# This is calculated at the time you login")
if (hex_gen0 == hex_gen1):
print ("\n[✔] Hashes Matched !")
print ("[✔] Password Verified !")
else:
print ("\n[✘] Hashes Didn't Matched !")
print ("[✘] Verification Failed !")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment