Guest User

Untitled

a guest
Oct 10th, 2015
517
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. import os
  2. import base64
  3. import hashlib
  4. import subprocess
  5. root = Tk()
  6. root.fileName = filedialog.askopenfilename( filetypes = ( ("Normal files", "*.jpeg*"),("All files", "*.*")))
  7.  
  8.  
  9.  
  10. print (root.fileName)
  11.  
  12. # os.startfile(root.fileName)
  13.  
  14. with open(root.fileName, "rb") as imageFile:
  15. str = base64.b64encode(imageFile.read())
  16. print (type(str).__name__)
  17. str.decode("utf-8")
  18. hashing = str.decode("utf-8")
  19. print(hashlib.md5(hashing.encode('utf-8')).hexdigest())
  20. HashImage = hashlib.md5(hashing.encode('utf-8')).hexdigest()
  21. f = open("imgDataHash.txt","a") #opens file with name of "imgData.txt"
  22. f.write(HashImage)
  23. f.close()
  24.  
  25.  
  26. #line comments:
  27. # 1-4 All of the modules. Typical stuff
  28. # 5-6 Makes a window then opens a file dialogue
  29. # 10 Just displays the name of the file and the directory.
  30. # 14 - 23 Opens the file, then converts it into bytes and places it into a string.
  31. # Prints out the type then decodes it into standard text. Prints out the hash number from the hashlib
  32. # Opens a text file then appends and writes the hash value.
  33. # This program is not meant to be taken too seriously as there is WAYYYYYYYY better alternatives. I am very proud of what I came up with
  34. # Works best with .jpeg for now. Tested with video but whats the point.
  35. # Finished: Oct 10, 2015, 1 am.
  36. # Make sure you have all of the library's. Do pip install ________
  37. # Must have python 3.4
Advertisement
Add Comment
Please, Sign In to add comment