How can I store password securely in MySQL and authenticate to external services

后端 未结 4 781
不知归路
不知归路 2021-01-07 02:49

Currently I have a PHP script that connect to a mail server via IMAP and parse new emails to MySQL. credentials to connect to the mail server are stored in MySQL using plain

4条回答
  •  一整个雨季
    2021-01-07 02:53

    MySQL supports a AES_ENCRYPT() function. You can encrypt as you INSERT it to the database, and decrypt it as you SELECT it back out.

    Read the documentation I linked to for examples.

    Then make sure you use port 993 for a TLS encrypted connection to the IMAP server when you imap_open() with the plaintext password.

提交回复
热议问题