PHP 8 Fixes

This commit is contained in:
earnolmartin 2022-04-21 09:45:33 -06:00
parent bd9b943f99
commit 948d80e418

View file

@ -48,10 +48,10 @@ function encryptPassword($password) {
$password_encrypted = "";
$encryption_string = sha1($net2ftp_settings["encryption_string"]);
if ($encryption_string % 2 == 1) { // we need even number of characters
$encryption_string .= $encryption_string{0};
$encryption_string .= $encryption_string[0];
}
for ($i=0; $i < strlen($password); $i++) { // encrypts one character - two bytes at once
$password_encrypted .= sprintf("%02X", hexdec(substr($encryption_string, 2*$i % strlen($encryption_string), 2)) ^ ord($password{$i}));
$password_encrypted .= sprintf("%02X", hexdec(substr($encryption_string, 2*$i % strlen($encryption_string), 2)) ^ ord($password[$i]));
}
return $password_encrypted;
// }
@ -102,7 +102,7 @@ function decryptPassword($password_encrypted) {
$password = "";
$encryption_string = sha1($net2ftp_settings["encryption_string"]);
if ($encryption_string % 2 == 1) { // we need even number of characters
$encryption_string .= $encryption_string{0};
$encryption_string .= $encryption_string[0];
}
for ($i=0; $i < strlen($password_encrypted); $i += 2) { // decrypts two bytes - one character at once
$password .= chr(hexdec(substr($encryption_string, $i % strlen($encryption_string), 2)) ^ hexdec(substr($password_encrypted, $i, 2)));
@ -746,4 +746,4 @@ function checkAdminUsernamePassword() {
?>
?>