Creating Single-Use Password for .exe app Created in MATLAB

10 visualizzazioni (ultimi 30 giorni)

Is there a way to create password for only one user/installation for .exe apps created in MATLAB.
I want to create a password for single user/installation so that other people don't get to copy the app and use.
Is there a way for this?

Thanks in advance.

Risposte (2)

Rahul
Rahul il 21 Gen 2025 alle 5:59
I understand that you wish to add a 'Single-use' password for your App created using MATLAB App Deisgner. According to my investigation, there is no direct way to add password protection to an App created in MATLAB.
There are a few workarounds which can be referred:
The following MathWorks File Exchange submission proposes to add an HTML component which can act as a Password protected layer.
The following steps can be followed for another workaround:
  • While creating a MATLAB App Designer app, add a 'TextField' component for the Password and a 'Label' component for the Login text.
  • Now add a 'ValueChanged' callback to your 'Password-TextField' component
  • Inside the callback function add a if-check for the correct 'Single-use' password, and add the call for function 'createComponents' there. Here is an example:
function PasswordEditFieldValueChanged(app, event)
value = app.PasswordEditField.Value;
if(value == "MATLAB")
createComponents(app);
end
end
  • Now since the 'Code View' of MATLAB App Designer is not editible, you can use the 'Export to .m file' feature from the dropdown of the 'Save' icon to obtain a .m file for the app which can be edited
  • Inside the .m file create a private function like 'createLogin' which would initialize the App's Password components. Here is an example:
function createLogin(app)
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure('Visible', 'off');
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = 'MATLAB App';
% Create PasswordEditFieldLabel
app.PasswordEditFieldLabel = uilabel(app.UIFigure);
app.PasswordEditFieldLabel.HorizontalAlignment = 'right';
app.PasswordEditFieldLabel.Position = [233 44 58 22];
app.PasswordEditFieldLabel.Text = 'Password';
% Create PasswordEditField
app.PasswordEditField = uieditfield(app.UIFigure, 'text');
app.PasswordEditField.ValueChangedFcn = createCallbackFcn(app, @PasswordEditFieldValueChanged, true);
app.PasswordEditField.Position = [306 44 100 22];
% Show the figure after all components are created
app.UIFigure.Visible = 'on';
end
  • inside 'createComponents' function initialize the component for showing 'You are Logged in!' and delete the 'Password-TextField' component
  • Now replace the call for 'createComponents' with 'createLogin' in the public methods
  • Run the .m file to test the App
  • Now run the 'mcc -m <app-name>' command to create an .exe file from the .m file.
Please refer to the attached .m file to know more.
Hope this can resolve your query. Thanks.

Walter Roberson
Walter Roberson il 21 Gen 2025 alle 16:21
In order to do what you want, you would have to program a control that connected to a server and authenticated to the server, with the server refusing authentication after the first time. It would be best if some of the control files were encrypted, to be decrypted by a key sent by the server.
Any attempt to create a stand-alone password system runs into two problems:
  • the user can roll back the filesystem, thus allowing multiple installations on the same system
  • the user can authenticate on multiple systems at the same time

Categorie

Scopri di più su Introduction to Installation and Licensing in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by