zoukankan      html  css  js  c++  java
  • springboot接口请求和响应解密加密

    这是一次巧合搜索到,但是也没有看懂是个啥样字。

    因为所有贴出来的只有代码,没有效果图。

    出于好奇,下载了代码

    运行起来了。

    但是没有效果

    开始我是下载这里的

    https://blog.csdn.net/hkk666123/article/details/114957024

    指引的代码

     https://gitlab.com/tpc.edu/encrypt/encrypt-body-demo

    一度怀疑。

    第二天又来看是什么原因。

    找到这个

    https://gitee.com/licoy/encrypt-body-spring-boot-starter

    根据他的指示替换了加密类

    运行Application 类

    也替换了

    import cn.licoy.encryptbody.annotation.EnableEncryptBody;
    控制器也替换了
    import cn.licoy.encryptbody.annotation.EnableEncryptBody;
    import org.springframework.boot.SpringApplication;

    终于看到了效果

    新建的运行类

    Application
    package edu.tpc.encryptbody;
    
    import cn.licoy.encryptbody.annotation.EnableEncryptBody;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @EnableEncryptBody
    @SpringBootApplication
    public class Application {
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    
    }

    新建的控制器

    TestController 
    package edu.tpc.encryptbody.controller;
    
    
    import cn.licoy.encryptbody.annotation.encrypt.EncryptBody;
    import cn.licoy.encryptbody.enums.EncryptBodyMethod;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.*;
    
    @Controller
    @RequestMapping("/test")
    public class TestController {
    
        @GetMapping
        @ResponseBody
        @EncryptBody(value = EncryptBodyMethod.AES)
        public String test(){
            return "hello world";
        }
    
    
    }

    效果图

    到此demo效果已经运行出来了。

    也使我想到了小鹅通 。

    他们保护资源的功能推测也是使用了此技术。

    通过此次发现。也让我感慨,原来保护资源本不只有类似微信支付签名那么一种方法。

    是多种多样的。

    需要好奇心,需要探索!

    其他参考文章和链接:

    https://blog.csdn.net/xxssyyyyssxx/article/details/88219298

    https://github.com/brix/crypto-js

    https://github.com/ishuibo/rsa-encrypt-body-spring-boot

  • 相关阅读:
    13.kubernetes之pv,pvc,configmap(带补充实例)
    1.docker 数据卷的备份和恢复(非大数据量)
    mysql基础 事务的认识和使用
    jdbc基础 (四) 批处理
    jdbc基础 (三) 大文本、二进制数据处理
    mysql使用基础 sql语句(一)
    linux下安装openssh-server
    jdbc基础 (二) 通过properties配置文件连接数据库
    jdbc基础 (一) MySQL的简单使用
    windows API 开发飞机订票系统 图形化界面 (四)
  • 原文地址:https://www.cnblogs.com/xiaohuasan/p/14917599.html
Copyright © 2011-2022 走看看