這是一次巧合搜索到,但是也沒有看懂是個啥樣字。
因為所有貼出來的只有代碼,沒有效果圖。
出於好奇,下載了代碼
運行起來了。
但是沒有效果
開始我是下載這里的
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