Can I encrypt an email password only in a .m file?

조회 수: 5 (최근 30일)
George Ebberson
George Ebberson 2018년 11월 3일
댓글: George Ebberson 2018년 11월 3일
I have written a GUI for a .exe file, and I intend to distribute it, certainly to friends but also perhaps on the file exchange as an easy way of giving everyone the newest version. As a user-friendly feature, if an error occurs I have written a sub-function to change preferences and send an email from a Gmail account I have setup specifically for this purpose, to itself, a simplified version of which is below:
% Get current prefs.
Code to store current prefs...
% Set to custom values.
setpref('Internet','E_mail','mygmail');
setpref('Internet','SMTP_Server','smtp.gmail.com');
setpref('Internet','SMTP_Username','mygmail');
setpref('Internet','SMTP_Password','mypassword');
props.setProperty('mail.smtp.auth','true');
props.setProperty('mail.smtp.starttls.enable','true');
sendmail('mygmail','errorname','errordetails');
% Restore prefs.
Code to restore original prefs...
Is there a way for me to encrypt the username and password strings? So far, I've considered moving this to a second function, and distributing it as a p-code along with the main function, but I ideally need a one-file solution as some of the people using it may not be too tech-savvy.
I've also considered just p-coding the entire thing, but from what I understand p-code isn't allowed on the file exchange?
Ideally, I need some mechanism to store the password in an encrypted form inside the m-file (I've thought about storing it as some psuedo-hash and including the maths to de-hash it, but everyone else will also have the maths and therefore the password), or, a way of sending an email from any PC, which may not be on my network, to the address I've setup.
I'm not objected to using another email service if anyone knows of another which may be more convenient in this case.
  댓글 수: 2
John D'Errico
John D'Errico 2018년 11월 3일
Yes, it is true that p-code is not allowed on the File Exchange.
Can you find a way to do what you want? Anything along these lines would be a total kluge. But could you? I doubt you could do something that would run better than a horse with two legs.
George Ebberson
George Ebberson 2018년 11월 3일
This was my worry. I fear I may have to just put the details in plaintext and not leave anything sensitive on the account.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Adding custom doc에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by