Spikeedoodles Posted December 27, 2014 Share Posted December 27, 2014 (edited) I would like to start out by saying I know this isn't anything complicated, but I've noticed lately that I really am bad with completing tools, so I decided to start out easy and move on from there. So what does this tool do? All it does is allow the user to select a file or folder and will has the file (or files) to MD5. The reason for making it? I needed a quick tool to hash files and decided to make my own because, you know, why not? Please give me advice! I'm not that good and would love to get better! Code: expandcollapse popup#include <Crypt.au3> #include <File.au3> #include <GUIConstantsEx.au3> Global $destFolder=0 main() Func main() Local $b_about, $b_help, $b_sd, $b_sf, $b_sdir GUICreate ("getMD5", 500, 100) $b_sdir=GUICtrlCreateButton ("Select Directory", 0, 1, 100, 20) $b_sf=GUICtrlCreateButton ("Select File", 100, 1, 100, 20) $b_sd=GUICtrlCreateButton ("Select Destination", 200, 1, 100, 20) $b_help=GUICtrlCreateButton ("Help", 300, 1, 100, 20) $b_about=GUICtrlCreateButton ("About", 400, 1, 100, 20) GUICtrlCreateLabel ("1. Select Destination Folder. This will be needed to save the hashes. Required for folder hashing, not file hashing."&@CRLF&"2. Choose whether to hash a single file or an entire folder."&@CRLF&"3. Follow the on-screen instructions", 1, 25, 498, 75) GUICtrlSetFont (-1, 10, 500) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $b_sdir Call ("byFolder") Case $b_sf Call ("byFile") Case $b_sd $destFolder=FileSelectFolder ("Select Destination Folder", @ScriptDir) Case $b_help MsgBox (64, "Help", "This application is only supported on Windows. -1 in the checksums file indicates a folder. If you encounter errors, please report them to ") Case $b_about MsgBox (64, "About", "This application was created by Adam Dean. For support, contact: ") EndSwitch WEnd EndFunc Func byFolder() local $md5, $folderopen, $files[65535], $c=1, $checksum, $foldercount=0, $sFile $folderopen=FileSelectFolder ("Choose Folder", @ScriptDir) $files=_FileListToArray ($folderopen) while $c <> $files[0]+1 $checksum&=$files[$c]&" :: "&_Crypt_HashFile ( $folderopen&"\"&$files[$c], $CALG_MD5 )&@CRLF $c=$c+1 if @error Then $foldercount=$foldercount+1 EndIf WEnd $sFile=FileOpen ($destFolder&"\MD5_Checksum"&@MDay&@Mon&@Year&".txt",1) if $destfolder="0" Then MsgBox (48, "No destination Folder Found", "Destination Folder not found. Please select a destination folder.") FileClose ($sFile) Return EndIf FileWrite ($sFile, "Total Files and Folders: "&$files[0]&@CRLF&"Total Folders found [Will not be hashed]: "&$foldercount&@CRLF&$checksum) MsgBox (64, "Hashing Complete", "Hashing complete.") FileClose ($sFile) EndFunc Func byFile() Local $fileOpen, $checksum $fileOpen=FileOpenDialog ("Select File to Hash", @ScriptDir, "All (*.*)") $checksum=_Crypt_HashFile ($fileOpen, $CALG_MD5 ) MsgBox (64, "Hashing Complete", "Hashing complete. Below is the hash of the selected file:"&@CRLF&$checksum) $sFile=FileOpen ($destFolder&"\MD5_Checksum"&@MDay&@Mon&@Year&".txt",1) if $destFolder=0 Then FileClose ($sFile) Return EndIf FileWrite ($sFile, "File Path: "&$fileOpen&@CRLF&"File hash: "&$checksum) EndFunc Edited December 27, 2014 by Spikeedoodles Link to comment Share on other sites More sharing options...
spudw2k Posted December 29, 2014 Share Posted December 29, 2014 Not a bad start. Nothing terribly wrong with the way you've started so far. The only thing that stands out to me is the redundant code in your script. While having duplcated coded in itself may not be detremental I've learned to embrace a more modular coding approach when I can. Can you think of a way to simplify your hashing routines so that it can be utilized for either files or folders instead of having functions for both? I also made an MD5 tool that you may be interested in reviewing just to see another way of doing things (MD5 Folder Enumarator in my signature). Also, my script example can perform a recursive enumeration which you may be interested in seeing one way how that can be done. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now