LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

String hash to define unique filenames

Hi!

 

I'm writing a program and need to cache some resulting binary files for my users.  The binary filenames would change depending on the settings the user selects (so that the process of the unique settings are saved and later retrieved by the program).

 

I tried to use an md5 hash from some VIs used to generate the hash from a file to try and accomplish this.  The problem I had was that I found that subtle setting changes (switching a boolean from TRUE to FALSE, for instance) wouldn't generate a unique md5 result.  Something about the algorithm was only considering certain parts of my input string.

 

I started to dig through the code, but am not very experienced on md5 hashes.

 

In order to generate the hash i flatten and manipulate into strings all my controls that define the settings (for instance, an array of file names along with some boolean options on how to process the set of file names).  Then I concatenate all these strings together and supply this as input to my MD5 VI which spits out something like: acd3245h21543s that i add a .bin to the end of and use as a file name.  When the same string is supplied (i.e., the exact same settings are selected) the program sees that the binary "cached" file with the results already exists and uses that.  This doesn't work if I don't get unique strings for the file name, which is what I'm struggling with.

 

Thanks for all your input!

 

temporary binary path generator.png

0 Kudos
Message 1 of 5
(3,287 Views)

 

 


@Nickerbocker wrote:

 

I tried to use an md5 hash from some VIs used to generate the hash from a file to try and accomplish this.  The problem I had was that I found that subtle setting changes (switching a boolean from TRUE to FALSE, for instance) wouldn't generate a unique md5 result.  Something about the algorithm was only considering certain parts of my input string.

 


 

Where does your MD5 VI come from? It's not the one shipped with LabVIEW or the OpenG solution. MD5 is not super strong like SHA-1 (or greater), but the string changing by the amount you mention should definitly trigger a new MD5 hash.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 2 of 5
(3,277 Views)

Gosh, I'm having a hard time finding it now.  It was on the NI website and its original purpose was to calculate the MD5 for a file I think.  I had to take some of the subVIs and manipulate them to work for my process which is probably where the error is because the difference of the characters 'TRUE' and 'FALSE' at the end of my string doesn't always produce different MD5 results from my VI.

 

If there is a MD5 VI that ships with LabVIEW, I'm having a hell of a time finding it.  I'm on LabVIEW 2010 Professional Development System.  Would you recommend the OpenG one?  

 

I try to avoid installing all those OpenG VIs as I probably only ever use 1% of them, there is also a lot of overlap with the included NI VIs.  I guess I dislike how the ctrl-space quick bar will select the OpenG VIs instead of the built-in ones while I'm coding.  Just one more thing to keep track of and make sure I have installed whenever I upgrade LabVIEW to the newer version.

0 Kudos
Message 3 of 5
(3,235 Views)

I found a better approach to what I was trying to accomplish which negated the need for caching data.

0 Kudos
Message 4 of 5
(3,219 Views)

 


@Nickerbocker wrote:

 

If there is a MD5 VI that ships with LabVIEW, I'm having a hell of a time finding it.  I'm on LabVIEW 2010 Professional Development System.  Would you recommend the OpenG one?

 

 


 

If I hit ctrl-spacebar and type MD5 I get two results, one for the NI one called 'MD5Checksum file' which is located in the advanced file paletted, the other one is the OpenG result which takes a string as input.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 5 of 5
(3,212 Views)