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.

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

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?