Created
November 4, 2012 19:32
-
-
Save mouuff/4013217 to your computer and use it in GitHub Desktop.
Script to check the hash of a file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: iso-8859-15 -*- | |
#you must have python2.7 and wxPython | |
import wx | |
import sys | |
import hashlib | |
class MyFrame(wx.Frame): | |
def __init__(self, *args, **kwds): | |
kwds["style"] = wx.DEFAULT_FRAME_STYLE | |
wx.Frame.__init__(self, *args, **kwds) | |
self.label_1 = wx.StaticText(self, -1, "Doc: drag and drop the file on the icon to show the md5 checksum\nhash:") | |
try: | |
with open(sys.argv[1]) as file: | |
md5hash = hashlib.md5(file.read()).hexdigest() | |
except: | |
md5hash = "" | |
self.text_ctrl_1 = wx.TextCtrl(self, -1, md5hash, style=wx.TE_READONLY) | |
self.__set_properties() | |
self.__do_layout() | |
def __set_properties(self): | |
self.SetTitle(" Py MD5CHECKSUM ") | |
def __do_layout(self): | |
sizer_1 = wx.BoxSizer(wx.VERTICAL) | |
grid_sizer_1 = wx.GridSizer(2, 1, 0, 0) | |
grid_sizer_1.Add(self.label_1, 0, wx.EXPAND, 0) | |
grid_sizer_1.Add(self.text_ctrl_1, 0, wx.EXPAND, 0) | |
sizer_1.Add(grid_sizer_1, 1, wx.EXPAND, 0) | |
self.SetSizer(sizer_1) | |
sizer_1.Fit(self) | |
self.Layout() | |
if __name__ == "__main__": | |
app = wx.PySimpleApp(0) | |
wx.InitAllImageHandlers() | |
frame_1 = MyFrame(None, -1, "") | |
app.SetTopWindow(frame_1) | |
frame_1.Show() | |
app.MainLoop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment