News, tips, advice, support for Windows, Office, PCs & more. Tech help. No bull. We're community supported by donations from our Plus Members, and proud of it
Home icon Home icon Home icon Email icon RSS icon
  • PowerShell Hashing Tool

    Posted on RetiredGeek Comment on the AskWoody Lounge

    Home Forums Tools PowerShell Hashing Tool

    • This topic has 6 replies, 2 voices, and was last updated 2 months ago.
    Viewing 5 reply threads
    • Author
      Posts
      • #2210597 Reply
        RetiredGeek
        AskWoody MVP

        Hey Y’all,

        Continuing my social distancing I’ve combined two of my file hashing scripts into a single script that will both check and generate file hashes. The program has a -setup switch that will automatically generate a desktop shortcut to run the program and also add an entry into the SendTo menu to allow you to select a file in file explorer and send it to the program.

        When generating a hash it will report it and also copy it to the clipboard for your convenience.

        For downloaded files just paste the provided hash value into the field, after selecting the hash algorithm and it will tell you if it matches the newly calculated value.

        After downloading the file and unzipping it, in PowerShell enter: get-help [d:path]Check-FileHash.ps1 -fullย  and read the included documentation.

        Check-FileHash.zip: Check-FileHash
        MD5 Hash for Check-FileHash.ps1: F07929245F69628FD4AAB8BBFDD77C06
        MD5 Hash for Check-FIleHash.zip: EFA5E1539BCAD808B0B077356F66A21D

        HTH ๐Ÿ˜Ž

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

        Attachments:
        3 users thanked author for this post.
      • #2210949 Reply
        RetiredGeek
        AskWoody MVP

        Hey Y’all,

        Sorry the brain just won’t shut down some times. Here’s version 6.1.

        What’s new:

        • Wider menu & text fields so you can see longer file specs.
        • Paste Hash button that will appear if there is text on the clipboard and allow you to paste it in. Of course, the program can’t tell if the clipboard contains a hash or something else, that’s up to you!
        • Replaced OK button with a context sensitive button. When you select or pass a file it will show as Generate. If you add a Hash it will change to Check. If you use the Paste Hash button this will happen automatically. If you type the hash in (who would want to do that) you need to use the tab key to change the button, but if you just click it it will still check the hash vs generate a new one.

        Check-Hash.zip: Check-FileHash-V6-1
        Zip MD5 Hash: E56E9206BB9D65ED3121F540832004BB
        PS1 MD5 Hash: 7FA4275C09886A69ADA6F1DCF5D17812

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

        Attachments:
      • #2210956 Reply
        Rick Corbett
        AskWoody_MVP

        RG – You’re just showing off now. ๐Ÿ™‚

        But seriously, dead impressed… thank you.

        Of course, the program canโ€™t tell if the clipboard contains a hash or something else

        Given that hashes follow a regular pattern, can you not use RegEx to check/filter the clipboard contents?

        • #2210957 Reply
          RetiredGeek
          AskWoody MVP

          Rick,

          I’m not really up on RegEx and since there are several algorithms I don’t really know how to do it. I’ve done some very very basic RegEx but it still twists my brain in knots. Reminds me of algebra a+b*c, just give me the d…m numbers already! LOL

          I do however check the length of the hash once it is entered to make sure it matches the selected algorithm.

          If you need a project for social distancing give it a go. I’ll be more than happy to incorporate it with credit!

          ๐Ÿ˜Ž

          May the Forces of good computing be with you!

          RG

          PowerShell & VBA Rule!
          Computer Specs

      • #2210967 Reply
        Rick Corbett
        AskWoody_MVP

        I bought all of Jack Dunnings’ books – a bundle including A Beginner’s Guide to Using Regular Expressions in AutoHotkey.

        I fell at the first hurdle…ย  ๐Ÿ™

        … so don’t hold your breath! ROFL

      • #2211154 Reply
        RetiredGeek
        AskWoody MVP

        Rick,

        Check clipboard for hash value…DONE!

        Sorry, can’t let a challenge go. I had a boss who knew and exploited that to no end. LOL

        # Check to see if clipboard contains a valid HEX value!
        $CBVal = Get-Clipboard
        $CBLen = $CBVal.Length
        $CKLen = (& {Switch ($CBLen) {
                              16 {$True ; Break}
                              32 {$True ; Break}
                              40 {$True ; Break}
                              64 {$True ; Break}
                              96 {$True ; Break}
                             128 {$True ; Break}
                         Default {$False}
                            }
                           } 
                        )
        If ($CKLen -eq $True) {
          $CBHex = $CBVal -match "^[0-9A-Fa-f]"
        }
        Else {$CBHex = $False}
        

        Check-FileHash v6.2 .zip: Check-FileHash-V6-2
        .ZIP File MD5 Hash: 9F919B3DBEB01843A512ABDF0AEACEC4
        .ps1 File MD5 Hash: BAB502C9064C961DD09348A61EEB7B6F

        Note: if the pasted hash’s length does not match the length required by the algorithm you’ll get a message to that effect and the hash field will be cleared. However, you can still use the button to re-paste it after you change the algorithm.

        HTH ๐Ÿ˜Ž

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

        Attachments:
      • #2211165 Reply
        Rick Corbett
        AskWoody_MVP

        Sorry, canโ€™t let a challenge go.

        There you go… I had every confidence in you. ๐Ÿ™‚

        (And I know exactly what you mean… I had a similar boss. Darn those NLP courses he went on…)

    Viewing 5 reply threads

    Please follow the -Lounge Rules- no personal attacks, no swearing, and politics/religion are relegated to the Rants forum.

    Reply To: PowerShell Hashing Tool

    You can use BBCodes to format your content.
    Your account can't use Advanced BBCodes, they will be stripped before saving.