Jump to content


Photo
* * * * * 1 votes

MD5 Hash (MD5 Package)

closed review md5

  • This topic is locked This topic is locked
47 replies to this topic

#1 jgcode

jgcode

    LabVIEW Renegade

  • OpenG
  • PipPipPipPipPipPip
  • 2,397 posts
  • Location:Australia
  • Version:LabVIEW 2009
  • Since:2005

Posted 29 August 2011 - 12:15 AM

This OpenG Review is closed. See Summary Post here. Please start a new thread to discuss new changes to this VI. Please PM me if there are any issues with this thread.

Community,

This VI was in the Candidates folder for the String Package.

isMD5.png

It has been sitting in there for a while therefore, I have just gone ahead and posted as is (so the license will be migrated on confirmation from the author etc...).

What are you thoughts on this VI?
  • Would you like to see such a function in OpenG?
  • Can you optimize the code?
  • It may be better suited in e.g. Comparison Package?
  • Should it be rejected?
Kind regards







Jonathon Green
OpenG Developer

Attached File  Is an MD5.vi   7.91K   136 downloads
Attached File  TEST - Is an MD5.vi   20.54K   128 downloads
Code is in LabVIEW 2009

#2 jgcode

jgcode

    LabVIEW Renegade

  • OpenG
  • PipPipPipPipPipPip
  • 2,397 posts
  • Location:Australia
  • Version:LabVIEW 2009
  • Since:2005

Posted 29 August 2011 - 08:29 AM

I propose that we use RegEx and clean up the BD.
Not sure of the best way to handle the error, above is an example to maintain the VI's interface.

md5.png

Attached File  Is an MD5.vi   7.91K   60 downloads
Code is in LabVIEW 2009

#3 jcarmody

jcarmody

    The 500 club

  • Premium Member
  • 801 posts
  • Location:North Carolina, United State, Earth
  • Version:LabVIEW 2012
  • Since:2007

Posted 29 August 2011 - 10:10 AM

A Regex would be slower, I would ignore the error (if using Match Regular Expression) and the \w will include non-hex characters.

Is an MD5_BD.png
LabVIEW Help_2011-08-29_06-03-39.png

Resistance is Mandatory

No rulers
No masters
NO CONSENT

 


#4 jgcode

jgcode

    LabVIEW Renegade

  • OpenG
  • PipPipPipPipPipPip
  • 2,397 posts
  • Location:Australia
  • Version:LabVIEW 2009
  • Since:2005

Posted 29 August 2011 - 10:17 AM


and the \w will include non-hex characters.


:o
Of course! Thx!
Does it always have to be lower case hex only as per these examples?

#5 Phillip Brooks

Phillip Brooks

    The 500 club

  • Members
  • PipPipPipPipPip
  • 758 posts
  • Location:Boston, MA
  • Version:LabVIEW 8.6
  • Since:1999

Posted 29 August 2011 - 11:15 AM

The RFC states that it must be lower case...

http://www.ietf.org/rfc/rfc2831.txt

Let HEX(n) be the representation of the 16 octet MD5 hash n as astring of 32 hex digits (with alphabetic characters always in lowercase, since MD5 is case sensitive).


Edited by Phillip Brooks, 29 August 2011 - 11:15 AM.

Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T


#6 jgcode

jgcode

    LabVIEW Renegade

  • OpenG
  • PipPipPipPipPipPip
  • 2,397 posts
  • Location:Australia
  • Version:LabVIEW 2009
  • Since:2005

Posted 29 August 2011 - 12:05 PM

A Regex would be slower, I would ignore the error (if using Match Regular Expression) and the \w will include non-hex characters.

Is an MD5_BD.png
LabVIEW Help_2011-08-29_06-03-39.png


Yes RegEx is slower but your code with Match Pattern does not pass the Test VI?
I don't think Match Pattern supports Quantifiers? I am not sure? (I always find myself looking up Match Pattern help as its different to RegEx)
Can anyone confirm - can we use MP for this (it is much faster).

Anyways here is the fix from using any alphanumeric to specifying a character class based on Phillip's post.
(Sorry, I cut, pasted and edit from the GUID thread - thanks for pointing that out)

I had to update the original Test VI to fail MD5's that contain [A-F] range (see new VI attached).

Attached File  Is an MD5.vi   19.5K   71 downloads
Attached File  TEST - Is an MD5.vi   20.61K   67 downloads
Code is in LabVIEW 2009

Attached Thumbnails

  • Is MD5.png


#7 jcarmody

jcarmody

    The 500 club

  • Premium Member
  • 801 posts
  • Location:North Carolina, United State, Earth
  • Version:LabVIEW 2012
  • Since:2007

Posted 29 August 2011 - 01:14 PM

My only comment is that the Regex doesn't need the pipe. I don't understand why Match Pattern doesn't work, but it definitely doesn't.

Resistance is Mandatory

No rulers
No masters
NO CONSENT

 


#8 jgcode

jgcode

    LabVIEW Renegade

  • OpenG
  • PipPipPipPipPipPip
  • 2,397 posts
  • Location:Australia
  • Version:LabVIEW 2009
  • Since:2005

Posted 29 August 2011 - 01:27 PM

My only comment is that the Regex doesn't need the pipe. I don't understand why Match Pattern doesn't work, but it definitely doesn't.


I can take the alternation metacharacter out if no one likes it in there - no dramas. (Unsure if it impacts performance or not).

#9 asbo

asbo

    I have no idea what you're talking about... so:

  • V I Engineering, Inc.
  • 1,273 posts
  • Version:LabVIEW 2011
  • Since:2008

Posted 29 August 2011 - 01:55 PM

Agreed, the alternation character is unnecessary. It'll work just the same, but it changes the logic of the expression (though it may have no performance impact).

The Match Pattern node does not support finite quantifiers, but dot and star work as expected. Because string length is an O(1) operation, maybe this is worth considering:

mplenmd5.png

Edit: Oops, had a-z as the character range, when it should have been a-f.

#10 jgcode

jgcode

    LabVIEW Renegade

  • OpenG
  • PipPipPipPipPipPip
  • 2,397 posts
  • Location:Australia
  • Version:LabVIEW 2009
  • Since:2005

Posted 29 August 2011 - 02:16 PM

Agreed, the alternation character is unnecessary. It'll work just the same, but it changes the logic of the expression (though it may have no performance impact).

The Match Pattern node does not support finite quantifiers, but dot and star work as expected. Because string length is an O(1) operation, maybe this is worth considering:



That's quite clever, and would be faster than RegEx.

#11 Wouter

Wouter

    Very Active

  • Members
  • PipPipPip
  • 103 posts
  • Version:LabVIEW 2011
  • Since:2006

Posted 30 August 2011 - 11:25 AM

My question... why would you ever want to test if a string looks like it is a md5 string?

Further I had much rather see VI's in OpenG which could create SHA1 and SHA2 hashes. Maybe ask Ton... https://bitbucket.or...rc/ee5c00d513e7

Edited by Wouter, 30 August 2011 - 11:38 AM.


#12 jgcode

jgcode

    LabVIEW Renegade

  • OpenG
  • PipPipPipPipPipPip
  • 2,397 posts
  • Location:Australia
  • Version:LabVIEW 2009
  • Since:2005

Posted 30 August 2011 - 11:36 AM

My question... why would you ever want to test if a string looks like it is a md5 string?


Most likely for data validation.
Of course the main reason for the review is verify whether this would be a useful function (and then how to implement it, if it is useful).

  • Should it be rejected?



So, please continue to let us know either way.

#13 dannyt

dannyt

    Extremely Active

  • Premium Member
  • 369 posts
  • Location:Devon UK
  • Version:LabVIEW 2011
  • Since:2007

Posted 30 August 2011 - 02:09 PM

My question... why would you ever want to test if a string looks like it is a md5 string? Further I had much rather see VI's in OpenG which could create SHA1 and SHA2 hashes. Maybe ask Ton... https://bitbucket.or...rc/ee5c00d513e7


I sort of agree with the question above, what is the use case for checking a string just looks like an MD5 string, it is either a correct valid md5 string for something or it is not. Maybe I am just not seeing the obvious here.

Danny

#14 Phillip Brooks

Phillip Brooks

    The 500 club

  • Members
  • PipPipPipPipPip
  • 758 posts
  • Location:Boston, MA
  • Version:LabVIEW 8.6
  • Since:1999

Posted 30 August 2011 - 03:53 PM


I sort of agree with the question above, what is the use case for checking a string just looks like an MD5 string, it is either a correct valid md5 string for something or it is not. Maybe I am just not seeing the obvious here.

Danny


Lets say you have a very large file that you want to verify (the LabVIEW 2011 image :) )

Before extracting and installing, you might want to verify the file. The time to generate the MD5 from the downloaded file may be significant. If you are going to compare the results of a time consuming operation with an invalid string, you will be wasting time (by re-downloading a file that may be good).

It is not easy to visually read or count the characters of an MD5 checksum...

Now is the right time to use %^<%Y-%m-%dT%H:%M:%S%3uZ>T


#15 Ton Plomp

Ton Plomp

    How many lines per hour? Zero!

  • Premium Member
  • 1,980 posts
  • Location:Netherlands
  • Version:LabVIEW 2012
  • Since:2000

Posted 01 September 2011 - 10:49 AM

If we are going to implement this, I wouldn't want it to be strict regarding the case, one of the reasons being that LabVIEW using %x formatter outputs uppercast hex-values.

Regarding the SHA hashes, yes my intention is to offer that code in the OpenG package, however I haven't got time to write unit tests for the SHA and HMAC hashing, though I have a complete set of unit test's for AES cyper/decypher routines.

Ton

#16 François Normandin

François Normandin

    Son of Scotland

  • Premium Member
  • 1,081 posts
  • Location:Montréal, QC
  • Version:LabVIEW 2012
  • Since:1999

Posted 01 September 2011 - 12:35 PM

*
POPULAR

This VI was in the Candidates folder for the String Package.


I'd find more natural to find this in the MD5 palette.

François [frɑ̃swa], CLA


#17 jgcode

jgcode

    LabVIEW Renegade

  • OpenG
  • PipPipPipPipPipPip
  • 2,397 posts
  • Location:Australia
  • Version:LabVIEW 2009
  • Since:2005

Posted 07 September 2011 - 01:06 AM

In summary:
  • Add this VI to OpenG
  • Move to MD5 package
  • Allow non-strict capitalization
  • Implement code similar to this:

Posted Image

With the non-strict capitalization issue, could an optional Boolean flag called "Strict Capitalization" (default = F) be added to the interface?
Would that be a good feature to have?

#18 Ton Plomp

Ton Plomp

    How many lines per hour? Zero!

  • Premium Member
  • 1,980 posts
  • Location:Netherlands
  • Version:LabVIEW 2012
  • Since:2000

Posted 07 September 2011 - 09:48 AM

If we are going to use this functionality, we nood to change the MD5 hash-vi with an extra output.
CUrrently the VI outputs a binary string, that should be converted to a hex-string to produce a valid MD5-hash.

#19 asbo

asbo

    I have no idea what you're talking about... so:

  • V I Engineering, Inc.
  • 1,273 posts
  • Version:LabVIEW 2011
  • Since:2008

Posted 07 September 2011 - 06:54 PM

I'm not sure I see the value in implementing a strict option. Unless you're actually evaluating whether something is following MD5 spec, the case of your hex string is irrelevant to the data it contains. There's trivial overhead in exposing the option to do this, but the execution of a mixed-case regular expression suffers ~20% performance penalty in some brief benchmarks.

I like Ton's idea RE: the hex string and would actually go as far to say that the string should be the only output - I've never had a use case where I need an MD5 in binary. It's always been for display or inclusion as a checksum (like VIPM does for package files and the like).

#20 jgcode

jgcode

    LabVIEW Renegade

  • OpenG
  • PipPipPipPipPipPip
  • 2,397 posts
  • Location:Australia
  • Version:LabVIEW 2009
  • Since:2005

Posted 07 September 2011 - 09:27 PM

...but the execution of a mixed-case regular expression suffers ~20% performance penalty in some brief benchmarks.


No, i was thinking that the flag would select the correct RegEx string to use in the MP primitive. So overhead should be negligible.





Also tagged with one or more of these keywords: closed review, md5