记录前后端接口使用AES+RSA混合加解密

news2024/9/21 16:27:57

一、前言

由于项目需求,需要用到前后端数据的加解密操作。在网上查找了了相关资料,但在实际应用中遇到了一些问题,不能完全满足我的要求。

以此为基础(前后端接口AES+RSA混合加解密详解(vue+SpringBoot)附完整源码)进行了定制化的改造,以提高代码的效率和易用性

二、工具类

请参考前言中引入的链接,复制
后端加密工具类:AESUtils、RSAUtils、MD5Util、ApiSecurityUtils
替换Base64,使用jdk内置的
AESUtils、ApiSecurityUtils

Base64.getEncoder().encodeToString
Base64.getDecoder().decode

RSAUtils,之所以这个工具类使用以下方法,因为它会报Illegal base64 character a

Base64.getMimeEncoder().encodeToString
Base64.getMimeDecoder().decode

前端加密工具类

三、后端实现代码

3.1、请求返回
import lombok.Data;
import org.springframework.stereotype.Component;

/**
 * @author Mr.Jie
 * @version v1.0
 * @description 用于返回前端解密返回体的aeskey和返回体
 * @date 2024/8/11 下午4:12
 **/
@Data
@Component
public class ApiEncryptResult {
    private String aesKeyByRsa;
    private String data;
    private String frontPublicKey;
}
3.2、注解
import org.springframework.web.bind.annotation.Mapping;

import java.lang.annotation.*;

/**
 * @author Mr.Jie
 * @version v1.0
 * @description 加解密算法
 * @date 2024/8/12 上午9:19
 **/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Mapping
@Documented
public @interface SecurityParameter {
    /**
     *  入参是否解密,默认解密
     */
    boolean isDecode() default true;

    /**
     * 输出参数是否加密,默认加密
     **/
    boolean isOutEncode() default true;
}
3.3、异常处理
/**
 * @author Mr.Jie
 * @version v1.0
 * @description 解密数据失败异常
 * @date 2024/8/12 上午9:43
 **/
public class DecryptBodyFailException extends RuntimeException {
    private String code;

    public DecryptBodyFailException() {
        super("Decrypting data failed. (解密数据失败)");
    }

    public DecryptBodyFailException(String message, String errorCode) {
        super(message);
        code = errorCode;
    }

    public DecryptBodyFailException(String message) {
        super(message);
    }

    public String getCode() {
        return code;
    }
}
3.4、解密信息输入流
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;

import java.io.IOException;
import java.io.InputStream;

/**
 * @author Mr.Jie
 * @version v1.0
 * @description 解密信息输入流
 * @date 2024/8/12 上午9:43
 **/
@NoArgsConstructor
@AllArgsConstructor
public class DecryptHttpInputMessage implements HttpInputMessage {

    private InputStream body;

    private HttpHeaders headers;

    @Override
    public InputStream getBody() throws IOException {
        return body;
    }

    @Override
    public HttpHeaders getHeaders() {
        return headers;
    }
}
3.5、接口数据解密
import cn.hutool.core.convert.Convert;
import com.alibaba.fastjson.JSONObject;
import com.longsec.encrypt.exception.DecryptBodyFailException;
import com.longsec.encrypt.utils.ApiSecurityUtils;
import com.longsec.encrypt.utils.MD5Util;
import com.longsec.common.redis.RedisUtils;
import com.longsec.common.utils.StringUtils;
import com.longsec.encrypt.annotation.SecurityParameter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.MethodParameter;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvice;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * @author Mr.Jie
 * @version v1.0
 * @description 接口数据解密 核心的方法就是 supports,该方法返回的boolean值,
 * 决定了是要执行 beforeBodyRead 方法。而我们主要的逻辑就是在beforeBodyRead方法中,对客户端的请求体进行解密。
 * RequestBodyAdvice这个接口定义了一系列的方法,它可以在请求体数据被HttpMessageConverter转换前后,执行一些逻辑代码。通常用来做解密
 * 本类只对控制器参数中含有<strong>{@link org.springframework.web.bind.annotation.RequestBody}</strong>
 * @date 2024/8/12 上午9:43
 **/
@Slf4j
@RestControllerAdvice
@Component
public class DecodeRequestBodyAdvice implements RequestBodyAdvice {

    @Autowired
    private RedisUtils redisUtils;
    protected static String jsPublicKey = "";

    @Override
    public boolean supports(MethodParameter methodParameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
        //如果等于false则不执行
        return methodParameter.getMethod().isAnnotationPresent(SecurityParameter.class);
    }

    @Override
    public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) throws IOException {
        // 定义是否解密
        boolean encode = false;
        SecurityParameter serializedField = parameter.getMethodAnnotation(SecurityParameter.class);
        //入参是否需要解密
        if (serializedField != null) {
            encode = serializedField.isDecode();
        }
        log.info("对方法method :【" + parameter.getMethod().getName() + "】数据进行解密!");
        inputMessage.getBody();
        String body;
        try {
            body = IOUtils.toString(inputMessage.getBody(), StandardCharsets.UTF_8);
        } catch (Exception e) {
            throw new DecryptBodyFailException("无法获取请求正文数据,请检查发送数据体或请求方法是否符合规范。");
        }
        if (StringUtils.isEmpty(body)) {
            throw new DecryptBodyFailException("请求正文为NULL或为空字符串,因此解密失败。");
        }
        //解密
        if (encode) {
            try {
                // 获取当前的ServletRequestAttributes
                ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
                if (attributes != null) {
                    // 获取原始的HttpServletRequest对象
                    HttpServletRequest request = attributes.getRequest();
                    // 从请求头中获取X-Access-Token
                    String token = request.getHeader("X-Access-Token");
                    if (StringUtils.isEmpty(token)) {
                        throw new DecryptBodyFailException("无法获取请求头中的token");
                    }
                    // 使用token进行进一步操作
                    JSONObject jsonBody = JSONObject.parseObject(body);
                    if (null != jsonBody) {
                        String dataEncrypt = jsonBody.getString("data");
                        String aeskey = jsonBody.getString("aeskey");
                        jsPublicKey = jsonBody.getString("frontPublicKey");
                        String md5Token = MD5Util.md5(token);
                        String privateKey = Convert.toStr(redisUtils.getCacheObject(md5Token + "privateKey"));
                        body = ApiSecurityUtils.decrypt(aeskey, dataEncrypt, privateKey);
                    }
                }
                InputStream inputStream = IOUtils.toInputStream(body, StandardCharsets.UTF_8);
                return new DecryptHttpInputMessage(inputStream, inputMessage.getHeaders());
            } catch (DecryptBodyFailException e) {
                throw new DecryptBodyFailException(e.getMessage(), e.getCode());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        InputStream inputStream = IOUtils.toInputStream(body, StandardCharsets.UTF_8);
        return new DecryptHttpInputMessage(inputStream, inputMessage.getHeaders());
    }

    @Override
    public Object afterBodyRead(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
        return body;
    }

    @Override
    public Object handleEmptyBody(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) {
        return body;
    }

    //这个方法为获取前端给后端用于加密aeskey的rsa公钥
    public static String getJsPublicKey() {
        return jsPublicKey;
    }
}
3.6、响应数据的加密处理
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.longsec.encrypt.annotation.SecurityParameter;
import com.longsec.encrypt.utils.ApiEncryptResult;
import com.longsec.encrypt.utils.ApiSecurityUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.MethodParameter;
import org.springframework.core.annotation.Order;
import org.springframework.http.MediaType;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;

/**
 * @author Mr.Jie
 * @version v1.0
 * @description 响应数据的加密处理
 * 本类只对控制器参数中含有<strong>{@link org.springframework.web.bind.annotation.ResponseBody}</strong>
 * 或者控制类上含有<strong>{@link org.springframework.web.bind.annotation.RestController}</strong>
 * @date 2024/8/12 上午9:43
 **/
@Order(1)
@ControllerAdvice
@Slf4j
public class EncryptResponseBodyAdvice implements ResponseBodyAdvice {

    private final ObjectMapper objectMapper;

    public EncryptResponseBodyAdvice(ObjectMapper objectMapper) {
        this.objectMapper = objectMapper;
    }

    @Override
    public boolean supports(MethodParameter methodParameter, Class aClass) {
        //这里设置成false 它就不会再走这个类了
        return methodParameter.getMethod().isAnnotationPresent(SecurityParameter.class);
    }

    @Override
    public Object beforeBodyWrite(Object body, MethodParameter methodParameter, MediaType mediaType, Class aClass, ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse) {
        if (body == null) {
            return null;
        }
        serverHttpResponse.getHeaders().setContentType(MediaType.TEXT_PLAIN);
        String formatStringBody = null;
        try {
            formatStringBody = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(body);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
        log.info("开始对返回值进行加密操作!");
        // 定义是否解密
        boolean encode = false;
        //获取注解配置的包含和去除字段
        SecurityParameter serializedField = methodParameter.getMethodAnnotation(SecurityParameter.class);
        //入参是否需要解密
        if (serializedField != null) {
            encode = serializedField.isOutEncode();
        }
        log.info("对方法method :【" + methodParameter.getMethod().getName() + "】数据进行加密!");
        if (encode) {
            String jsPublicKey = DecodeRequestBodyAdvice.getJsPublicKey();
            if (StringUtils.isNotBlank(jsPublicKey)) {
                ApiEncryptResult apiEncryptRes;
                try {
                    apiEncryptRes = ApiSecurityUtils.encrypt(JSON.toJSONString(formatStringBody), jsPublicKey);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
                return apiEncryptRes;
            }
        }
        return body;
    }
}
3.7、获取RSA公钥接口
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author Mr.Jie
 * @version v1.0
 * @description 获取RSA公钥接口
 * @date 2024/8/11 下午4:04
 **/
@CrossOrigin
@RestController
@RequestMapping("api/encrypt")
@RequiredArgsConstructor
public class EncryptApi {
    private final RedisUtils redisUtil;

    @GetMapping("/getPublicKey")
    public Object getPublicKey() throws Exception {
        //获取当前登陆账号对应的token,这行代码就不贴了。
        String token = "42608991";
        String publicKey = "";
        if (StringUtils.isNotBlank(token)) {
            Map<String, String> stringStringMap = RSAUtils.genKeyPair();
            publicKey = stringStringMap.get("publicKey");
            String privateKey = stringStringMap.get("privateKey");
            String md5Token = MD5Util.md5(token);
            //这个地方的存放时间根据你的token存放时间走
            redisUtil.setCacheObject(md5Token + "publicKey", publicKey);
            redisUtil.setCacheObject(md5Token + "privateKey", privateKey);
        }
        return R.ok(publicKey);
    }
}
3.8、对外接口调用
import com.alibaba.fastjson.JSONObject;
import com.l.api.param.ApiParam;
import com.l.common.annotation.Log;
import com.l.common.core.controller.BaseController;
import com.l.common.enums.BusinessType;
import com.l.common.encrypt.annotation.SecurityParameter;
import com.l.tools.HttpClientUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author Mr.Jie
 * @version v1.0
 * @description 统一对外接口
 * @date 2024/8/1 下午3:59
 **/
@Api(tags = "统一对外接口")
@CrossOrigin
@Controller
@RequiredArgsConstructor
@RequestMapping("/api/uniformInterface")
public class UniformInterfaceApi extends BaseController {
    private final HttpClientUtil httpClientUtil;

    @PostMapping("/invoke")
    @ResponseBody
    @Log(title = "统一接口", businessType = BusinessType.API)
    @ApiOperation(value = "统一接口", produces = "application/json")
    @SecurityParameter
    public Object invoke(@RequestBody ApiParam dto) {
        try {
            JSONObject param = JSONObject.parseObject(dto.getJsonParam());
            Object obj = httpClientUtil.getDubboService(dto.getServiceKey(), param, true);
            return success(obj);
        } catch (Exception e) {
            return error("服务调用异常:" + e.getMessage());
        }
    }
}

四、前端实现代码

4.1、axios请求统一处理
import Axios from 'axios'
import {getRsaKeys, rsaEncrypt, rsaDecrypt, aesDecrypt, aesEncrypt, get16RandomNum} from '../utii/encrypt'

/**
 * axios实例
 * @type {AxiosInstance}
 */
const instance = Axios.create({
    headers: {
        x_requested_with: 'XMLHttpRequest'
    }
})
let frontPrivateKey
/**
 * axios请求过滤器
 */
instance.interceptors.request.use(
    async config => {
        if (sessionStorage.getItem('X-Access-Token')) {
            // 判断是否存在token,如果存在的话,则每个http header都加上token
            config.headers['X-Access-Token'] = sessionStorage.getItem('X-Access-Token')
        }
        if (config.headers['isEncrypt']) {
            // config.headers['Content-Type'] = 'application/json;charset=utf-8'
            if (config.method === 'post' || config.method === 'put') {
                const {privateKey, publicKey} = await getRsaKeys()
                let afterPublicKey = sessionStorage.getItem('afterPublicKey')
                frontPrivateKey = privateKey
                //每次请求生成aeskey
                let aesKey = get16RandomNum()
                //用登陆后后端生成并返回给前端的的RSA密钥对的公钥将AES16位密钥进行加密
                let aesKeyByRsa = rsaEncrypt(aesKey, afterPublicKey)
                //使用AES16位的密钥将请求报文加密(使用的是加密前的aes密钥)
                if (config.data) {
                    let data = aesEncrypt(aesKey, JSON.stringify(config.data))
                    config.data = {
                        data: data,
                        aeskey: aesKeyByRsa,
                        frontPublicKey: publicKey
                    }
                }

                if (config.params) {
                    let data = aesEncrypt(aesKey, JSON.stringify(config.params))
                    config.params = {
                        params: data,
                        aeskey: aesKeyByRsa,
                        frontPublicKey: publicKey
                    }
                }
            }
        }
        return config
    },
    err => {
        return Promise.reject(err)
    }
)
/**
 * axios响应过滤器
 */
instance.interceptors.response.use(
    response => {
        //后端返回的通过rsa加密后的aes密钥
        let aesKeyByRsa = response.data.aesKeyByRsa
        if (aesKeyByRsa) {
            //通过rsa的私钥对后端返回的加密的aeskey进行解密
            let aesKey = rsaDecrypt(aesKeyByRsa, frontPrivateKey)
            //使用解密后的aeskey对加密的返回报文进行解密
            var result = response.data.data;
            result = JSON.parse(JSON.parse(aesDecrypt(aesKey, result)))
            return result
        } else {
            return response.data
        }
    }
)

export default instance
4.2、调用示例
export const saveStudent = (data) => {
    return axios.request({
        url: api.invoke,
        method: 'post',
        headers: {
            //需要加密的请求在头部塞入标识
            isEncrypt: 1
        },
        data
    })
}

五、实现效果

请求加密数据
请求参数
返回加密数据
返回参数

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2043636.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

讲解 狼人杀中的买单双是什么意思

买单双这个概念通常出现在有第三方的板子中 比如 咒狐板子 丘比特板子 咒狐板子 第一天狼队只要推掉预言家 第二天就可以与咒狐协商绑票 推出其他好人 以及丘比特板子 如果拉出一个人狼链 那么如果孤独再连一个狼人 那么 狼队第一天就可以直接派人上去拿警徽&#xff0c;这样…

NDP(Neighbor Discovery Protocol)简介

定义 邻居发现协议NDP&#xff08;Neighbor Discovery Protocol&#xff09;是IPv6协议体系中一个重要的基础协议。邻居发现协议替代了IPv4的ARP&#xff08;Address Resolution Protocol&#xff09;和ICMP路由设备发现&#xff08;Router Discovery&#xff09;&#xff0c;…

萌啦数据插件使用情况分析,萌啦数据插件下载

在当今数字化时代&#xff0c;数据已成为企业决策与个人分析不可或缺的重要资源。随着数据分析工具的日益丰富&#xff0c;一款高效、易用的数据插件成为了众多用户的心头好。其中&#xff0c;“萌啦数据插件”凭借其独特的优势&#xff0c;在众多竞品中脱颖而出&#xff0c;成…

[数据集][图像分类]肾脏病变分类数据集识别囊肿肿瘤结石数据集11756张4类别

数据集类型&#xff1a;图像分类用&#xff0c;不可用于目标检测无标注文件 数据集格式&#xff1a;仅仅包含jpg图片&#xff0c;每个类别文件夹下面存放着对应图片 图片数量(jpg文件个数)&#xff1a;11756 分类类别数&#xff1a;4 类别名称:["cyst","normal&…

上海晋名室外危化品暂存柜助力燃料电池行业

近日又有一个SAVEST室外危化品暂存柜项目成功验收交付使用。 用户是一家致力于为燃料电池行业提供研发、创新解决方案和技术支持的科技型中小企业。 用户在日常经营活动中涉及到氢气实验过程中的安全问题&#xff0c; 4月初在网上看到上海晋名室外暂存柜系列很感兴趣&#xf…

[EC Final 2020] ICPC2020 东亚赛区决赛重现赛题解

比赛链接:EC Final 2020 和 cyx20110930 组的队&#xff0c;用他的号交的题。顺便帮助他橙名&#xff0c;好耶&#xff01;&#xff08;rk 25&#xff0c;我俩各写 2 道&#xff09; Problem B: 这道是 cyx20110930 写的&#xff0c;顺便安利(copy)一下他的题解。 题目意思…

html+css网页制作 化妆品电商4个页面

htmlcss网页制作 化妆品电商4个页面 网页作品代码简单&#xff0c;可使用任意HTML编辑软件&#xff08;如&#xff1a;Dreamweaver、HBuilder、Vscode 、Sublime 、Webstorm、Text 、Notepad 等任意html编辑软件进行运行及修改编辑等操作&#xff09;。 获取源码 1&#xff…

操作系统(Linux实战)-进程创建、同步与锁、通信、调度算法-学习笔记

1. 进程的基础概念 1.1 进程是什么&#xff1f; 定义&#xff1a; 进程是操作系统管理的一个程序实例。它包含程序代码及其当前活动的状态。每个进程有自己的内存地址空间&#xff0c;拥有独立的栈、堆、全局变量等。操作系统通过进程来分配资源&#xff08;如 CPU 时间、内…

LabVIEW光纤管道泄漏检测系统

光纤管道泄漏定位系统利用干涉型光纤传感器和数据采集卡进行信号获取与处理&#xff0c;实现了高灵敏度的泄漏点定位。通过软件对泄漏信号进行实时降噪处理和数据库管理&#xff0c;提高了系统的自动化和智能化水平。 项目背景&#xff1a; 长输管道在石油、天然气等行业中发挥…

【C++第十二课-多态】多态概念、多态原理

目录 多态的概念概念多态形成的条件虚函数的重写虚函数重写的两个例外 多态的题目C11增加的关于多态的关键字finaloverride 多态原理虚函数表指针 vfptr多态的实现静态绑定和动态绑定打印虚函数表补充 抽象类概念接口继承和实现继承 多态的概念 概念 具体点就是去完成某个行为…

Centos安装Kafka

安装Kafka 安装Java&#xff0c;因为Kafka运行需要JDK运行环境 sudo yum install java-1.8.0-openjdk-devel.x86_64如果不知道JDK版本&#xff0c;可以使用下面命令查看可用的JDK版本 sudo yum search openjdk添加EPEL仓库 sudo yum install epel-release下载Kafka 先去查看…

nginx初步学习

Nginx 安装 官方源码包下载地址&#xff1a;nginx: download 配置一台虚拟机尽量给的配置高些这样速度快些。 下载文件并解压 加载对应模块 ./configure --prefix/usr/local/nginx \ --usernginx \ # 指定nginx运行用户 --groupnginx \ # 指定ng…

BUUCTF 极客大挑战2019 Upload 1

上传图片&#xff0c;然后抓包 我们可以看到回显 我们改一下content-type 这里我们可以改一下filename为100.phtml&#xff0c;也可以不改 然后我们通过该指令查看一下是否被解析 我们发现flag就在这里 我们cat一下&#xff0c;得到了flag

kubernetes集群下部署mysql 8.0.20单机数据库

一、背景&#xff1a; 因为业务需求&#xff0c;需要在kubernetes集群下部署一个mysql数据库 8.0.20版本的单机服务。 具体实施过程如下&#xff1a; 二、实施部署mysql数据库&#xff1a; mysql 8.0.20的镜像&#xff1a; dockerhub.jiang.com/jiang-public/mysql:8.0.20-stjh…

Windows有哪些免费好用的PDF编辑器推荐?

不是所有PDF编辑器都免费&#xff0c;但我推荐的这3个一定免费简单好用&#xff01;&#xff01; 1、转转大师PDF编辑器 点击直达链接>>pdftoword.55.la 转转大师PDF编辑器是一款专业的PDF编辑工具&#xff0c;功能丰富&#xff0c;操作简单&#xff0c;作为微软office…

ZYNQ—vitis—网口传输信号波形数据

ZYNQ—vitis—网口传输信号波形数据 工程功能&#xff1a;ADC采集信号&#xff0c;将波形数据通过BRAM传输到PS端&#xff0c;然后用UDP以太网发送。&#xff08;附加&#xff1a;ILA观察信号&#xff0c;发送的数据包含帧头&#xff0c;&#xff09; FPGA端——用BRAM将信号传…

如何在一个页面上定位多个关键词?

我应该针对多个关键词优化我的页面吗&#xff1f; 对于大多数网站来说&#xff0c;答案都是肯定的。 如果你制定的策略是仅针对一个关键字优化你的网页&#xff0c;这可能会导致一些问题。例如&#xff0c;如果一个网页只能使用一个关键字&#xff0c;那么他们可能会开发出非…

vue2利用html2canvas+jspdf动态生成多页PDF

业务需求中&#xff0c;前端把页面上的内容导出为图片&#xff0c;pdf&#xff0c;excel是常有的事。当然&#xff0c;这些工作后端也是能做。秉着前端是万能的理念&#xff0c;今天就站在前端的角度上&#xff0c;来实现将页面内容导出为pdf&#xff0c;实现指定div内容导出&a…

【数据结构篇】~复杂度

标题【数据结构篇】~复杂度 前言 C语言已经学完了&#xff0c;不知道大家的基础都打得怎么样了&#xff1f; 无论怎么说大家还是要保持持续学习的状态&#xff0c;来迎接接下来的挑战&#xff01; 现在进入数据结构的学习了&#xff0c;希望大家还是和之前一样积极学习新知识…

ESP32人脸识别开发--人脸识别模型(六)

ESP-DL ESP-DL 为**神经网络推理**、**图像处理**、**数学运算**以及一些**深度学习模型**提供 API&#xff0c;通过 ESP-DL 能够快速便捷地将乐鑫各系列芯片产品用于人工智能应用 ESP-DL 无需借助任何外围设备&#xff0c;因此可作为一些项目的组件&#xff0c;例如可将其作…