Encrypted file for account info in email script

4 vues (au cours des 30 derniers jours)
Alexander Ketzle
Alexander Ketzle le 20 Jan 2022
Modifié(e) : Pravarthana P le 16 Fév 2022
I have this script to send emails using MATLAB:
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','E_mail','EMAIL ADDRESS');
setpref('Internet','SMTP_Username','EMAIL USERNAME');
setpref('Internet','SMTP_Password','EMAIL PASSWORD');
props = java.lang.System.getProperties;
props.setProperty('mail.smtp.auth','true');
props.setProperty('mail.smtp.socketFactory.class', 'javax.net.ssl.SSLSocketFactory');
props.setProperty('mail.smtp.socketFactory.port','465');
sendmail('RECEIVER ADDRESS','I did it','I can also send attatchments');
and while the script itself (when filled in with the correct information) does function as intended, the inclusion of the email username and password in the .m file is obviously insecure. Does anyone know of a way of both encrypting a file with the information, and getting matlab to read it?
  1 commentaire
Rik
Rik le 20 Jan 2022
Anybody with access to the file containing your password and the code you wrote to decrypt it, will have access to the password. That is fundamental to the way this code will work.
If you actually want something secure, at the very least do NOT invent your own encryption and decryption method. Store the key in a third place.

Connectez-vous pour commenter.

Réponses (1)

Pravarthana P
Pravarthana P le 16 Fév 2022
Modifié(e) : Pravarthana P le 16 Fév 2022
Hi Alexander Ketzle, it can be understood that you are trying to protect the data that is present in your MATLAB source code. This is a known issue, for which you can find the possible workarounds as stated below:
1. You can replace your SMTP server username and password in your MATLAB preferences with blank values. You can do this by typing the following commands at the MATLAB command prompt:
setpref('Internet','SMTP_Username','');
setpref('Internet','SMTP_Password','');
2. You can always convert into Pcode that obfuscates the code although this doesn’t provide complete encryption of your code.
You may find the following link helpful:

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by