01-08-2024 12:16 PM - edited 01-08-2024 12:28 PM
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)
01-08-2024 12:57 PM
01-08-2024 12:58 PM
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?
01-08-2024 01:05 PM
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
01-09-2024 02:07 AM
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:
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.
01-09-2024 12:05 PM
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