LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Incripting Data Output

Solved!
Go to solution

Many of my programs use the write to measurement file.vi or the write to spreadsheet file.vi and save the output data as a standard tab-deligniated spreadsheet, .lvm file.  My question is if there is a way to make an incripted file so that it is saved in a read-only mode, so that you can't just go in and change the data that was saved.

0 Kudos
Message 1 of 5
(2,983 Views)
Solution
Accepted by LarsUlrich

You can set the file permission with this tool. This has nothing to do with encryption.

 

However, it does not really present a very hard boundary. Instead of trying to prevent modification, maybe it is sufficient to detect modifications, e.g. by including a hash of the entire file somewhere.

 

Of course you could encrypt the entire file so it can only be read using specific tools.

Message 2 of 5
(2,977 Views)

First thing you have to do is decide how serious you are about the encryption.  Do you want it to be robust so that the CIA can't crack it, or just simple enough to stop the casual user from modifying it?

 

Here's one simple way of doing it. Convert the data string to an array of bytes, add one to each byte and save as a binary file.  To decrypt it, read in the binary file, substract one from each byte, then convert to string.

 

You could get fancier by adding/subtracting a "password" byte instead of just adding/subtracting one.

Message 3 of 5
(2,963 Views)

I decided that just adding 1 to each byte is too simple for encryption.  Basically, it just moves every character over one in the alphabet so that "Hello" becomes "Ifmmp".

 

That might be enough to stop the causal user, but could be easily cracked.

 

To make it just a little better, I multiply each byte by 2 before saving.  Besides scrambling the data more, there are a couple of other things you have to watch out for:  Multiplying a byte results in a Long, which is 32 bits instead of 8 bits.  So the data file will be four times longer.  When you read in the data file, you have to count the total number of bytes and divide by 4.  Also, you have to make sure you read in a Long data type instead of a byte.

 

Other than that, it works like the previous version.  I have to warn you, this still results in weak encryption, but it will be sufficient to keep casual users from messing with files.

Message 4 of 5
(2,955 Views)

Yeah I guess incription wasn't the right word.  I don't care who sees the file, I just want to make sure that it cannot be altered.

0 Kudos
Message 5 of 5
(2,942 Views)