Neha Beniwal
Neha Beniwal

Reputation: 653

Securing a password/string in source code

I have created an application where I could send a mail with Mail API. Therefore, for that I had to provide the email id and password of the source mailbox.

Refer the code below:

Mail sender = new Mail("sourceEmailID", "sourcePassword");
sender.sendMail("Subject","Body","sourceEmailID", "destinationEmailID");

Now, I dont want to provide the harcoded password inside my source code. Infact I want to convert it into asterisk form or any other secured form.

But the value shouldn't change when calling the original form.

What should I do to for this!

Thanks in advance.

Upvotes: 1

Views: 66

Answers (1)

Shanu Gupta
Shanu Gupta

Reputation: 3807

You will need the plain text password in any case while creating Mail Object. To improve security, you should:

  • Encrypt the password and keep it in code/property file/database. Also store the secret key in code/property file/database. Decrypt it at the time of creating Mail object
  • Use SSL/TLS/https

This should provide you enough security.

Upvotes: 1

Related Questions