douyuefei3546 2018-04-21 00:54
浏览 453
已采纳

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.

  • 写回答

1条回答

  • dongyi7966 2018-04-21 01:32
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作