How to password protect mat files

17 visualizaciones (últimos 30 días)
Yoav Livneh
Yoav Livneh el 6 de Ag. de 2013
Hi all.
I am looking for a way to password protect a .mat file. My requirements are that it cannot be changed or deleted without a password.
I'm not looking for encryption, I just don't want someone else to accidentally delete it, since it is on a network drive. I want to be able to load and save the file using MATLAB.
I thought about creating a password protected .zip file, but MATLAB cannot unzip protected files.
Any suggestions would be appreciated.

Respuesta aceptada

Jan
Jan el 7 de Ag. de 2013
Set the write-protection of a file:
fileattrib('myfile.m', '-w')
But look in the documentation: doc fileattrib:
'w' Write access (Windows and UNIX platforms). Results differ by platform and
application. For example, even though fileattrib disables the "write"
privilege for a folder, making it read only, files in the folder could be
writable for some platforms or applications.
You can change the permissions by calling system commands, so please explain on which OS the function should run.
  5 comentarios
Jan
Jan el 8 de Ag. de 2013
This sounds to be a perfect task for a backup. E.g. store a duplicate file in a deeply nested folder and let Matlab check if both files are identical. Then a missing, moved or changed file can be fixed silently or verbosely by a simple file copy.
The much smaller complexity of this method and the independence from the OS will be a great improvement for the stability.
Yoav Livneh
Yoav Livneh el 8 de Ag. de 2013
Thank you very much for the suggestions. My boss really liked the copy pretection idea, so I will go with that one.
But I have also added that every time someone runs the calibration program, MATLAB will save a backup of the previous calibration file before saving, just in case.

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 6 de Ag. de 2013
Protection against deletion needs to be at the operating system level, not at the MATLAB level.
Generally speaking, you would set the ownership of the file to be different than any userid that will have normal access to the file, and you set the file to be only writable by the owner. The mechanisms to do these vary with the operating system you are using.
  3 comentarios
Walter Roberson
Walter Roberson el 7 de Ag. de 2013
That might be difficult. Which operating system will be used?
Yoav Livneh
Yoav Livneh el 7 de Ag. de 2013
I will be using Windows XP

Iniciar sesión para comentar.

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by