diff --git a/core/class/helper.class.php b/core/class/helper.class.php index 3b244970..cd05e330 100644 --- a/core/class/helper.class.php +++ b/core/class/helper.class.php @@ -682,4 +682,26 @@ class helper return $text; } + /** + * Cryptage + * @param string $key la clé d'encryptage + * @param string $string la chaine à coder + * @return string + */ + public static function encrypt($string, $key) { + $encrypted = openssl_encrypt($string, "AES-256-CBC", $key, 0, substr(md5($key), 0, 16)); + return base64_encode($encrypted); + } + + /** + * Décryptage + * @param string $key la clé d'encryptage + * @param string $string la chaine à décoder + * @return string + */ + public static function decrypt($string, $key) { + $decrypted = openssl_decrypt(base64_decode($string), "AES-256-CBC", $key, 0, substr(md5($key), 0, 16)); + return $decrypted; + } + } diff --git a/core/core.php b/core/core.php index a1a8000e..c44de30e 100644 --- a/core/core.php +++ b/core/core.php @@ -1149,7 +1149,7 @@ class common $mail->SMTPSecure = true; $mail->SMTPAuth = $this->getData(['config', 'smtp', 'auth']); $mail->Username = $this->getData(['config', 'smtp', 'username']); - $mail->Password = $this->getData(['config', 'smtp', 'password']); + $mail->Password = helper::decrypt($this->getData(['config', 'smtp', 'password']),$this->getData(['config', 'smtp', 'host'])); } } @@ -1183,7 +1183,7 @@ class common return $mail->ErrorInfo; } } catch (Exception $e) { - return $e->getMessage(); + return $mail->ErrorInfo; } } diff --git a/core/module/config/config.php b/core/module/config/config.php index dbba2910..4488d8ad 100644 --- a/core/module/config/config.php +++ b/core/module/config/config.php @@ -460,7 +460,7 @@ class config extends common 'auth' => $this->getInput('smtpAuth', helper::FILTER_BOOLEAN), 'secure' => $this->getInput('smtpSecure', helper::FILTER_STRING_SHORT), 'username' => $this->getInput('smtpUsername', helper::FILTER_STRING_SHORT), - 'password' => $this->getInput('smtpPassword', helper::FILTER_STRING_SHORT), + 'password' => helper::encrypt($this->getInput('smtpPassword', helper::FILTER_STRING_SHORT),$this->getInput('smtpHost', helper::FILTER_STRING_SHORT)), 'from' => $this->getInput('smtpFrom', helper::FILTER_MAIL, true), ], 'seo' => [