Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import base64
- import hashlib
- import subprocess
- root = Tk()
- root.fileName = filedialog.askopenfilename( filetypes = ( ("Normal files", "*.jpeg*"),("All files", "*.*")))
- print (root.fileName)
- # os.startfile(root.fileName)
- with open(root.fileName, "rb") as imageFile:
- str = base64.b64encode(imageFile.read())
- print (type(str).__name__)
- str.decode("utf-8")
- hashing = str.decode("utf-8")
- print(hashlib.md5(hashing.encode('utf-8')).hexdigest())
- HashImage = hashlib.md5(hashing.encode('utf-8')).hexdigest()
- f = open("imgDataHash.txt","a") #opens file with name of "imgData.txt"
- f.write(HashImage)
- f.close()
- #line comments:
- # 1-4 All of the modules. Typical stuff
- # 5-6 Makes a window then opens a file dialogue
- # 10 Just displays the name of the file and the directory.
- # 14 - 23 Opens the file, then converts it into bytes and places it into a string.
- # Prints out the type then decodes it into standard text. Prints out the hash number from the hashlib
- # Opens a text file then appends and writes the hash value.
- # 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
- # Works best with .jpeg for now. Tested with video but whats the point.
- # Finished: Oct 10, 2015, 1 am.
- # Make sure you have all of the library's. Do pip install ________
- # Must have python 3.4
Advertisement
Add Comment
Please, Sign In to add comment