r/PythonProjects2 • • Feb 11 '20

hash stuff


errmsg = "sys err"
print("[1] encryptor")
print("[2] decryptor")
what = input("c:\\> ")

if what == "1":
     i = 2
     while i == 2:
          inp = input("word: ")
          if inp == "break":
               break
          hasdinp = hashlib.md5(inp.encode('utf-8').strip()) .hexdigest()
          print("le hash: %s"%hasdinp )
          print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")

elif what == "2":
     a = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
     print("\n password cracker \n")
     fileu = input("file directory: ")
     inpin = input("whats the method: ")
     if inpin.lower() == "md5":
          hashu = input("what is the md5 hash: ")
          try:
               fileo = open(fileu, "r")
          except:
               print(errmsg)
               
          counter = 1
          for passes in fileo:
               md5has = hashlib.md5(passes.encode("utf-8").strip()).hexdigest()
               print('trying pw %d: %s'%(counter, passes))
               print(a)
               counter += 1
               if hashu == md5has:
                    print("\n password found: %s \n"%(passes))
                    fileo.close()
                    break
          else:
               print("404 hash not found")
      
     if inpin.lower() == "sha1":
     
          hashu = input("what is the sha1 hash: ")
          try:
               fileo = open(fileu, "r")
          except:
               print(errmsg)
               
          counter = 1
          for passes in fileo:
               sha1has = hashlib.sha1(passes.encode("utf-8").strip()).hexdigest()
               print('trying pw %d: %s'%(counter, passes))
               print(a)
               counter += 1
               if hashu == sha1has:
                    print("\n password found: %s \n"%(passes))
                    fileo.close()
                    break
          else:
               print("404 hash not found")

     if inpin.lower() == "sha256":
        
          hashu = input("what is the sha256 hash: ")
          try:
               fileo = open(fileu, "r")
          except:
               print(errmsg)
               
          counter = 1
          for passes in fileo:
               sha256has = hashlib.sha256(passes.encode("utf-8").strip()).hexdigest()
               print('trying pw %d: %s'%(counter, passes))
               print(a)
               counter += 1
               if hashu == sha256has:
                    print("\n password found: %s \n"%(passes))
                    fileo.close()
                    break
                    
          else:
               print("404 hash not found")
else:
     print(errmsg) ```
0 Upvotes

5 comments sorted by

5

u/bobdobbsjr Feb 12 '20

Two things. First, you need to fix the formatting. Second, it helps to include some kind of description instead of just posting code.

-4

u/thot_patrol6942 Feb 12 '20

are you on mobile? if so i would probably go to the desktop site since i did format it. thanks for the review tho.

3

u/bobdobbsjr Feb 12 '20

No, I'm on desktop.

From the line "``` import hashlib" to the line "counter = 1" there is no indentation. It's like it's one big line that has been word wrapped.

From the line "counter = 1" to the second from the last line, that is all in a code block. The last line isn't in the code block

1

u/thot_patrol6942 Feb 12 '20

well. this is strange to say the least, i swear i formatted it properly.

1

u/stratcat22 Feb 12 '20

I’m on mobile and it’s not formatted properly for me either.