车辆视频检测器linux版对于密码中包含敏感字符的处理方法

由于密码中含有敏感字符,导致前端页面异常,图标变灰,坐标拾取打不开图像等,主要原因是:密码比较前后不一致,左边是Abc_110+,右边是:Abc_110%2B,对于此问题,特别编写了url编码函数,利用Qt的编码方法对所有敏感字符进行统一处理,然后再进行比较,就OK了,注意opencv的rtsp格式符中不能包含敏感字符,但是SDK登录时,还要使用原始密码,所以密码输入时,要按原始密码输入,使用过程中,需要编码的地方用编码。

cpp 复制代码
//检查是否为重复编码
bool isAlreadyEncoded(const QString &str) {
    // 检查字符串中是否存在 % 后跟两位十六进制数字的模式
    QRegularExpression regex("%[0-9A-Fa-f]{2}");
    return regex.match(str).hasMatch();
}
//检查密码中是否含有敏感字符,如果有则进行url编码,如:@转换为%40,+号转换为%2B等
QString safeEncode(const QString &input) {
    if (isAlreadyEncoded(input)) {
        // 如果已经编码,直接返回原始字符串
        return input;
    } else {
        // 如果未编码,进行编码
        return QString::fromUtf8(input.toUtf8().toPercentEncoding());
    }
}

//检测摄像头参数是否改变
bool DataObj_Camera::checkCamParams(){
    if(id<1 || id>8) return false;
        if(cameraparam.getIp()!=gCarDetectorParams.getCameraIP(id)||
            cameraparam.getUsername()!=gCarDetectorParams.getCameraUsername(id) ||
            safeEncode(cameraparam.getPassword())!=safeEncode(gCarDetectorParams.getCameraPassword(id)) ||
            cameraparam.getPort()!=gCarDetectorParams.getCameraPort(id) ||
            cameraparam.getType()!=gCarDetectorParams.getCameraType(id) ||
            cameraparam.getCodec()!=gCarDetectorParams.getCameraCodec(id) ||
            cameraparam.getInputMode()!=gCarDetectorParams.getCameraInputMode(id)||
            cameraparam.getInputChannel()!=gCarDetectorParams.getCameraInputChannel(id)){
        return false;
    }
    return true;
}
相关推荐
黑翼杰克斯20 分钟前
如何裁剪u-boot,保留其必要功能,使体积尽可能小
linux·1024程序员节
cellurw3 小时前
Day69 SQLite3动态库移植 + BMP图像解析显示 + 进度条控件设计与动态文本管理
linux
nono牛3 小时前
Linux基础指令大全(快速上手)
linux·服务器·windows·智能手机
<但凡.3 小时前
Linux修炼:库制作与原理(一)
linux·运维·服务器
Maple_land5 小时前
编译器的“隐形约定”与本地变量:解锁Linux变量体系的关键密码
linux·运维·服务器·c++·centos
深思慎考6 小时前
微服务即时通讯系统(服务端)——Speech 语音模块开发(2)
linux·c++·微服务·云原生·架构·语音识别·聊天室项目
小蜜蜂爱编程6 小时前
Ubuntu无法开机Failed to activate swap /swapfile
linux·运维·ubuntu
阿巴~阿巴~6 小时前
CPU 指令集、权限与用户态内核态机制
linux·运维·服务器·指令集·权限·用户态内核态
小涵6 小时前
企业SRE/DevOps向的精通Linux课程培训课程
linux·运维·devops·1024程序员节
航Hang*7 小时前
第1章:初识Linux系统——第8节:查看/修改权限控制和ACL
linux·运维·服务器·笔记·操作系统