jQuery加密数据

Actually my problem is ridiculous. I provide security by adding header. When I add the encrypted data, the browser gives an error.

Code source output :

headers: {
    "Authorization": "���6���/��O��u�f�߁v2��",
},

Console Output

Browser detects:

headers: {
    "Authorization": "���6���/��O��
u�f�߁v2��",
},

PHP Code :

 headers: {
     "Authorization": "<?php echo $_SESSION['sID']; ?>",
 },

My Session Class :

class Session {

    public function __construct() {
        if(session_status() == PHP_SESSION_NONE) {
            session_start();
        }
        self::Encrypt('sID', session_id());
    }

    public static function Encrypt($Name, $Value) {
        if(!is_null($Value)) {
            $_SESSION[$Name] = openssl_encrypt($Value, Config::Get('Encrypt/Type'), Config::Get('Encrypt/Password'), OPENSSL_RAW_DATA, Config::Get('Encrypt/Session'));
            return $_SESSION[$Encrypt];
        }
        return false;
    }
 }

What is the problem? Does anyone have an idea ? Best regards !

Also : str_replace and trim tried its functions.

The return value of openssl_encrypt() with the OPENSSL_RAW_DATA flag set will generally not be a printable string. It will usually contain invalid UTF-8 characters, and may sometimes include characters which will interfere with Javascript code parsing, like quotation marks.

Don't use the OPENSSL_RAW_DATA flag here. Without this flag set, the function will return Base64-encoded output, which is more appropriate for your needs.