OS : Linux
PHP Version : 7.4.33
Software : Apache/2.4.6 (CentOS) PHP/7.4.33
Information System : Linux apprendre2 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64key = md5((string) $enc_key); $this->key_type = (string) $key_type; } /** * @return bool */ public static function supported() { /** @TODO: Should we inform the user about the security risk? and how? */ return true; } /** * Encrypt a string (Passwords). * * @param string $string value to encrypt * * @return string encrypted string */ public function encrypt($string) { $result = ''; for ($i = 0; $i < strlen($string); ++$i) { $char = substr($string, $i, 1); $key_char = substr($this->key, ($i % strlen($this->key)) - 1, 1); $char = chr(ord($char) + ord($key_char)); $result .= $char; } return BackWPup_Encryption::PREFIX . self::PREFIX . $this->key_type . base64_encode($result); } /** * Decrypt a string (Passwords). * * @param string $string value to decrypt * * @return string decrypted string */ public function decrypt($string) { if ( !is_string($string) || !$string || strpos($string, BackWPup_Encryption::PREFIX . self::PREFIX . $this->key_type) !== 0 ) { return ''; } $no_prefix = substr($string, strlen(BackWPup_Encryption::PREFIX . self::PREFIX . $this->key_type)); $encrypted = base64_decode($no_prefix, true); if ($encrypted === false) { return ''; } $result = ''; for ($i = 0; $i < strlen($encrypted); ++$i) { $char = substr($encrypted, $i, 1); $key_char = substr($this->key, ($i % strlen($this->key)) - 1, 1); $char = chr(ord($char) - ord($key_char)); $result .= $char; } return $result; } }