diff --git a/src/main/java/com/lhstack/controller/CryptoController.java b/src/main/java/com/lhstack/controller/CryptoController.java index 0b609ec8bde99361333801eed305320e4e349bf5..1cfbb56b8b297dcbee98975ed7b10c2c10be9908 100644 --- a/src/main/java/com/lhstack/controller/CryptoController.java +++ b/src/main/java/com/lhstack/controller/CryptoController.java @@ -1,24 +1,39 @@ package com.lhstack.controller; import java.util.Map; +import java.util.Optional; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.lhstack.utils.Aes; + import io.reactivex.Single; @RestController @RequestMapping("crypto") public class CryptoController { + + @Value("${aes.key:}") + private String defaultAesKey; + + @Value("${aes.iv:}") + private String defaultAesIv; @PostMapping("decrypt") public Single decrypt(@RequestBody Map body){ return Single.defer(() -> { - System.out.println(body); - return Single.just("hello world"); + String aesKey = body.getOrDefault("key", defaultAesKey); + String aesIv = body.getOrDefault("iv", defaultAesIv); + byte[] content = body.getOrDefault("content","").getBytes(); + return Single.fromCallable(() -> { + Optional resulOptional = Aes.decrypt(aesKey, aesIv, content); + return "hello world"; + }); }); } diff --git a/target/classes/com/lhstack/TemplateApplication.class b/target/classes/com/lhstack/TemplateApplication.class index 4585b1a0d2467699d927ab7b15f31fb60e4a0be5..88190ac1698b12bfc532377b107e1ff420953f1f 100644 Binary files a/target/classes/com/lhstack/TemplateApplication.class and b/target/classes/com/lhstack/TemplateApplication.class differ diff --git a/target/classes/com/lhstack/config/WebMvcConfiguration.class b/target/classes/com/lhstack/config/WebMvcConfiguration.class index 74c5f11b61d4df1b468b5ed4e4998ff51838168b..ae7e6c33b339fd27acc9ddf30e14b4958ce1a299 100644 Binary files a/target/classes/com/lhstack/config/WebMvcConfiguration.class and b/target/classes/com/lhstack/config/WebMvcConfiguration.class differ diff --git a/target/classes/com/lhstack/controller/CryptoController.class b/target/classes/com/lhstack/controller/CryptoController.class index 582a66ac611b18235fd7bf08bea1c62107355d10..67a585432b330ec90814d3b65b2c6683c107344d 100644 Binary files a/target/classes/com/lhstack/controller/CryptoController.class and b/target/classes/com/lhstack/controller/CryptoController.class differ diff --git a/target/classes/com/lhstack/utils/Aes.class b/target/classes/com/lhstack/utils/Aes.class index 26fb96c7c9e500646bea2ff2eba20b2f511df3f4..7e5ebd2a1e9050f62db5ba48c5ea334a965afc37 100644 Binary files a/target/classes/com/lhstack/utils/Aes.class and b/target/classes/com/lhstack/utils/Aes.class differ