rockmanvnx6

Hashing.py

Aug 14th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.16 KB | None | 0 0
  1. import hashlib
  2. def instruction():
  3.     print("-----COMMAND LIST-----")
  4.     print("/md5 value")
  5.     print("/sha256 value")
  6.     print("/sha512 value")
  7.     print("/md5-b value ----- brute force from 0 to value")
  8.     print("/sha512-b value ---- brute force from 0 to value")
  9.     print("/sha256-b value ---- brute force from 0 to value")
  10.  
  11. def takeInput(x):
  12.     x = input("Type in command (/help): ");
  13.     return x;
  14.  
  15. def printDict(dict,n):
  16.     for i in range(0,n):
  17.         print(i,dict[i])
  18.  
  19. store = {}
  20.  
  21. x = None
  22. x = takeInput(x);
  23. while(not False):
  24.     if(x == "/help"):
  25.        instruction()
  26.        x = takeInput(x)
  27.  
  28.     elif (x.startswith("/md5-b")):
  29.         target = x[7:]
  30.         n = int(target) + 1
  31.         for i in range(0,n):
  32.             targetx = str(i).encode('utf-8')
  33.             ans = hashlib.md5(targetx).hexdigest()
  34.             store[i] = ans
  35.         printDict(store,n)
  36.         x = takeInput(x)
  37.  
  38.     elif (x.startswith("/sha256-b")):
  39.         target = x[10:]
  40.         n = int(target) + 1
  41.         for i in range(0, n):
  42.             targetx = str(i).encode('utf-8')
  43.             ans = hashlib.sha256(targetx).hexdigest()
  44.             store[i] = ans
  45.         printDict(store, n)
  46.         x = takeInput(x)
  47.  
  48.     elif (x.startswith("/sha512-b")):
  49.         target = x[10:]
  50.         n = int(target) + 1
  51.         for i in range(0, n):
  52.             targetx = str(i).encode('utf-8')
  53.             ans = hashlib.sha512(targetx).hexdigest()
  54.             store[i] = ans
  55.         printDict(store, n)
  56.         x = takeInput(x)
  57.  
  58.     elif(x.startswith("/md5")):
  59.         target = x[5:].encode('utf-8')
  60.         ans = hashlib.md5(target).hexdigest()
  61.         print("md5: " + ans)
  62.         x = takeInput(x)
  63.  
  64.  
  65.     elif (x.startswith("/sha256")):
  66.         target = x[8:].encode('utf-8')
  67.         ans = hashlib.sha256(target).hexdigest()
  68.         print("sha256: " + ans)
  69.         x = takeInput(x)
  70.  
  71.     elif (x.startswith("/sha512")):
  72.         target = x[8:].encode('utf-8')
  73.         ans = hashlib.sha512(target).hexdigest()
  74.         print("sha512: " +ans)
  75.         x = takeInput(x)
  76.  
  77.     else:
  78.         print("Command is not found")
  79.         instruction()
  80.         x = takeInput(x)
Advertisement
Add Comment
Please, Sign In to add comment