Secure a SMTP password in PHP

后端 未结 2 696
你的背包
你的背包 2021-01-16 12:42

I\'m going to use the phpmailer class in my WordPress-plugin to support the use of SMTP in my e-mail function. Is it safe to store the password in the PHP code? I don\'t fee

2条回答
  •  既然无缘
    2021-01-16 13:27

    Essentially you can't - and there are many posts on here saying exactly that. You can however obfuscate it to keep opportunists away. The most straightforward way is to put your password in an external config file (which helps you avoid obvious mistakes like checking your password into github). You can encrypt it to some extent, but at some point you need to decrypt it with some other supposedly secret key, so you're back at square one.

    md5 and sha1 (or any other hashing function) have nothing to do with this question; hash functions are simply not applicable to this use case.

提交回复
热议问题