Showing results for 
Search instead for 
Did you mean: 

SHA-256 hash via LabVIEW

Go to solution

Hello everyone,


I am trying to perform a SHA-256 hash of all files in a folder via LabVIEW. 

I found this link:

So I thought I would try to incorporate this in my LabVIEW code. I have no experience calling .dlls through LabVIEW or incorporating .NET in my VIs.


I could access the SHA256Managed Class by starting a Constructor Node in LabVIEW, selecting mscorlib( In my case this was under C:\Windows\Microsoft.NET\Framework\v2.0.50727

I thought now all I had to do is go back to the original link (from microsoft, linked above) and look at the properties, methods and etcetera to find out how to select the folder and which method would give me the hash. 

I concluded (perhaps wrongly) that I would need to use ComputeHash (to get the results) with an inputStream which would reference to the folder I want to perform the SHA-256 hash on. However, I can't figure out how to pass on a reference to which folder I should select, because no matter what I do, I can't pass on a folder path to inputStream! 

What am I doing wrong?

Any help would be greatly appreciated


0 Kudos
Message 1 of 8
Accepted by topic author Interesting_Stuff

If you have LabVIEW 2020, you can use the integrated File Checksum (File >> Adv File Funcs >> File


If not, use Read Binary File to read the content of each file and use the "buffer" overload for ComputeHash. (Or create a DotNet FileStream object from the path).


To get the hash of the folder, you could concatenate the individual hashes and use ComputeHash once more.

0 Kudos
Message 2 of 8

Hi cord,

Thanks for the reply, I have done it for a single file, and when I convert my array containing the result to a string, I get a weird result:


This is my code

Any suggestions of what is wrong?


0 Kudos
Message 3 of 8
Accepted by topic author Interesting_Stuff

The hash is binary, not text. Change the display mode for your string control to Hex!

Rolf Kalbermatter
Averna BV
0 Kudos
Message 4 of 8

Also don't forget to Close the .Net refnum. Otherwise the object will stay in memory as long as your application is running. If you then executed this code multiple times, every time a new object will be created.

Rolf Kalbermatter
Averna BV
0 Kudos
Message 5 of 8

Thank you!

0 Kudos
Message 6 of 8

Ok, now the last weird thing is that when comparing the result of my hash vs some online hash tools, I get different results, but all online tools have the same results.


Any idea why?

0 Kudos
Message 7 of 8

Make sure you are reading the whole file, not just a single character 😉

And adding to what rolfk said, close the file reference from read binary file.

0 Kudos
Message 8 of 8