车辆视频检测器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;
}
相关推荐
zfxwasaboy3 小时前
Linux宏clamp(val, lo, hi)的作用
linux·运维·服务器
我爱学习好爱好爱5 小时前
Ansible 常用模块详解:lineinfile、replace、get_url实战
linux·python·ansible
吴声子夜歌6 小时前
TypeScript——基础类型(三)
java·linux·typescript
DA02216 小时前
系统移植-STM32MP1启动详解(BootROM)
linux·bsp·系统移植
春日见6 小时前
自驾算法的日常工作?如何提升模型性能?
linux·人工智能·机器学习·计算机视觉·自动驾驶
李彦亮老师(本人)6 小时前
【Linux系统】Rocky Linux 9.7操作系统简介
linux·运维·服务器·docker·kubernetes
minji...6 小时前
Linux 进程信号(二)信号的保存,sigset_t,sigprocmask,sigpending
linux·运维·服务器·网络·数据结构·c++·算法
A.A呐7 小时前
【Linux第二十章】socket
linux
何中应7 小时前
Grafana如何重置密码
linux·运维·服务器·grafana
charlie1145141918 小时前
2026年正点原子开发板移植方案——从0开始的Rootfs之路(3)inittab 与 init 系统:Linux 启动的“第一号进程“全解析
linux·驱动开发·学习·嵌入式开发·嵌入式linux