encryption of .mat files
Show older comments
*hello , i have stored the data of my application in .mat file , i edit and change the values of the variables throw my application , i don't want the other user to see the name of variables or the values , any suggested function or a way to encrypt the file ??
Thanks ALL*
Accepted Answer
More Answers (4)
Matt Kindig
on 18 Jul 2012
Edited: Matt Kindig
on 18 Jul 2012
1 vote
Hi Khaled,
This hasn't gotten any bites yet, so I thought I'd take a stab at it, although I am not an encryption expert by any means.
What access do you want the "other user" to have to your data? As I understand it, you basically want to encrypt your file such that someone else cannot open and read your data. I'm not sure how you'll be able to do that in a *.mat file-- if you use Matlab to save the data in MAT format, the file will be written in such a way that it can be opened with Matlab, as that is the purpose of the file format. I don't believe that Matlab has an equivalent of Excel's "Protect Workbook" or similar. You can encrypt m-files such that they can be executed without revealing the source code (using the 'pcode' function), but that is obviously something different than you want.
If you want to store your data in a format that is available for reading only for yourself (or a limited number of people), you are probably better off writing to a binary file and then using one of a number of standard encryption codes. A quick search of the File Exchange indicates a few encryption functions--Google I'm sure has countless more. How secure do you need the encryption?
Matt
2 Comments
khaled DAWOUD
on 18 Jul 2012
Edited: khaled DAWOUD
on 18 Jul 2012
Mahmoud
on 21 Aug 2016
Dear Khaled, Have you found any solution for your problem?
per isakson
on 18 Jul 2012
Edited: per isakson
on 18 Jul 2012
Matlab documentation:
New MAT-File Format Based on HDF5
In Version 7.3 (R2006b), you can save MAT-files in a format based on HDF5.
The v7.3 mat-file is documented and can be inspected with the hdf5-tools:
>> h5disp( 'mk.mat')
HDF5 mk.mat
Group '/'
Group '/#refs#'
Dataset 'a'
....
HDF5 is open and well supported.
In the "The Data Transfer Pipeline" of HDF5 it is possible to include your own code for encryption and decryption (and more common compression).
Thus, it should be doable - maybe.
2 Comments
khaled DAWOUD
on 18 Jul 2012
per isakson
on 18 Jul 2012
Edited: per isakson
on 19 Jul 2012
I picked up the info above from reading the documentation and hdf-forum. I cannot add much. Bad news:
- the size of the "v7.3 file" is much larger than the compressed default file
- might work for values but maybe not for names.
If you are serious about it why not ask tech-support.
khaled DAWOUD
on 18 Jul 2012
0 votes
David Leffingwell
on 12 Jun 2023
0 votes
If you are using the MATLAB Compiler, you can use the -s option to encrypt your data (e.g. MAT files) in addition to your M files. See here.
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!