LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SHA256 checksum for project folder

Spoiler
 

Hi, I'm trying to create one checksum for my project directory folder. The hash algorithm I'm using is SHA256. All the vis in the folder are interlinked so if I change code for any .vi, the checksum should be updated. This checksum is shown on the front panel and will be exported to a .txt file. This is what I have so far, I'm just not really sure how I can make it as just one checksum rather than multiple checksums for each file. (Note: I'm using LabVIEW 2020)

0 Kudos
Message 1 of 6
(664 Views)

Hi cayoute,

 

you could ZIP the whole folder into one archive file and calculate the checksum for that ZIP file…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(578 Views)

If this project folder has been part of a source code control like Git or SVN, those tools will help monitor the folder for any change.

 

What are you trying to achieve using the SHA256 checksum value?

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 3 of 6
(575 Views)

So I'm not using git or svn for source control with the project folder so that's why I'm trying to create my own checksum for security/file integrity with the SHA256

0 Kudos
Message 4 of 6
(568 Views)

If your goal is to have unmodifiable code, I would suggest building an EXE or a packed library. An executable is more user-friendly.

 

I would strongly recommend using source code control, regardless of what you're trying to do now. There are many good reasons for it. SVN is fairly easy to set up and use.

 

As for the hash, a couple of options:

 

  1. Your VI is polymorphic, so it probably has a version which accepts a string instead of a path. You could read the binary data of all the files, concatenate that and hash the result.
  2. You could hash each file and then concatenate the results and hash that.

 

Note that in any case, since you're saving the resulting hash to a text file, there's probably nothing preventing someone from changing it. If you decided to save it in the VI and the VI is in the folder, then saving the VI would change the hash. You could start saving it outside the folder and in places where users don't have write access, but it seems to be overly complicated.


___________________
Try to take over the world!
0 Kudos
Message 5 of 6
(464 Views)

The second option from @tst would look like this. NI doesn't expose the Byte Array Checksum.vi, only the File Checksum.vi. But you can find it in vi.lib.

 

You already have the array of file checksums and are concatenating it to a single string. Just use String to Byte Array and pass that byte array into Byte Array Checksum.vi

 

String Array SHA.png

Message 6 of 6
(440 Views)