Announcement

Collapse
No announcement yet.

Need a script to generate MD5 hash

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Need a script to generate MD5 hash

    Script needed for MD5 hash generation for a single string.
    The source string will be in HS Device #123
    The MD5 hash to be stored in HS Device #234 as 32 character string

    123 and 234 HS device reference numbers and are examples only. I will gladly substitute them in the script with the real values.

    It looks like pretty simple task as in many online samples it takes 2-3 lines code to produce MD5 hash for a single string.
    Unfortunately I'm not qualified to do it.

    #2
    https://www.geekshangout.com/a-simpl...to-a-md5-hash/

    Code:
    Sub Main(ByVal p As String)
    
        Const iRef = 123
        Const oRef = 456
    
        Dim iStr As String = hs.DeviceString(iRef)
        Dim oStr = md5sum(iStr)
    
        hs.SetDeviceString(oRef, oStr, True)
    
    End Sub
    
    Function md5sum(ByVal strToHash As String) As String
    
        Dim md5Obj As New Security.Cryptography.MD5CryptoServiceProvider
        Dim bytesToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash)
    
        bytesToHash = md5Obj.ComputeHash(bytesToHash)
    
        Dim strResult As String = ""
    
        For Each b As Byte In bytesToHash
            strResult += b.ToString("x2")
        Next
    
        Return strResult
    
    End Function

    Comment


      #3
      zwolfpack


      Thanks for the help. Added .vb to the script file and still getting this error in the log

      Event (Test scripting MD5) action Run Script could not be completed - action does not have a valid script file or immediate command.

      Getting the same error even if I try to execute a single command like this one

      hs.SetDeviceString (1234, "test", true)

      Comment


        #4
        Resolved. Thanks to jon00 who opened my eyes that I have to press the floppy disk icon every time to save any changes before running it.

        zwolfpack Thanks again for the script. It seems to be working as it does produce 32 byte MD5 hash. However I'm yet to test it with real data. Will do it pretty soon and let everyone know.

        P.S. Wondering what percentage of the users here know what is floppy disk and how many have actually hold one and out of those who have how many have hold the first generation of 8" size.

        Comment


          #5
          The trouble is that floppy disk doesn't loop like a floppy disk, in fact physically it's not even possible (disc isn't even centered, no slot to read the disc, etc). Looks more like a defective iPod LOL

          I've modified my HS4 to have a proper floppy:
          Click image for larger version

Name:	Screen Shot 2020-08-05 at 7.11.06 pm.png
Views:	66
Size:	58.4 KB
ID:	1408664

          What the actual?!? When I make a sarcastic remark or joke it is moderated/deleted.
          But you specifically go out of your way to label multiple HS4 issues that cause data loss/crash of HS4 to be "grumbles".
          I can't even begin to put into words how offensive this is.

          Comment


            #6
            Actually it looks very much like a 3.5 inch hard plastic disk IMHO. These had a metal cover that slid over the slot and a notch on a corner shaped much like the above image.

            Coming from someone who has no plans to upgrade to HS4 for at least a year, It's been interesting reading the acceptance (or lack of) of HS4 from the HS3 community. The lack of staff and experience in UX design comes to the forefront. I'm surprised that so many bugs or just incomplete functionality exist, but honestly I don't have details of the HS2 to HS3 change to compare to; too many years ago.

            I'm also curious why HST didn't write a "Changes in HS4 from HS3" document to ease existing users into this conversion and limit the negative comments related to just "change" and not real limitations of the new version. First impressions are lasting impressions as the expression goes. Maybe they assumed everyone was involved in the Beta and these changes were discussed there? It seems like just getting to this point was a monumental effort, and actual consideration before action didn't happen.

            I don't want to be considered a negative nanny, I'm a happy HST customer and hope they have great success. I'm just musing from the outside with no insider knowledge and can easily be off base.

            Hey macromark, am I missing the "HS4 introduction for HS3 Users" guide? Especially around UI changes like discussed above?

            ​​​​​​​

            Comment


              #7
              Originally posted by mterry63 View Post
              Actually it looks very much like a 3.5 inch hard plastic disk IMHO. These had a metal cover that slid over the slot and a notch on a corner shaped much like the above image.
              That above image was my fixed one - the image that appears in HS4 is a mutant Though I should clarify HST didn't develop that image it's part of a package they've bought - which also includes the real floppy I've swapped in.

              What the actual?!? When I make a sarcastic remark or joke it is moderated/deleted.
              But you specifically go out of your way to label multiple HS4 issues that cause data loss/crash of HS4 to be "grumbles".
              I can't even begin to put into words how offensive this is.

              Comment


                #8
                zwolfpack

                Tested the MD5 hash script with real data and it does work. Thanks, again.

                Comment

                Working...
                X