Cryptage SMTP
This commit is contained in:
parent
53b78bf61d
commit
0cd7a54904
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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' => [
|
||||
|
Loading…
Reference in New Issue
Block a user