Encrypted file for account info in email script

1 次查看(过去 30 天)
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 个评论
Rik
Rik 2022-1-20
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.

请先登录,再进行评论。

回答(1 个)

Pravarthana P
Pravarthana P 2022-2-16
编辑:Pravarthana P 2022-2-16
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:

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by