Auto commit

上级 a71ac9f0
package com.lhstack.controller; package com.lhstack.controller;
import java.util.Map; 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.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.lhstack.utils.Aes;
import io.reactivex.Single; import io.reactivex.Single;
@RestController @RestController
@RequestMapping("crypto") @RequestMapping("crypto")
public class CryptoController { public class CryptoController {
@Value("${aes.key:}")
private String defaultAesKey;
@Value("${aes.iv:}")
private String defaultAesIv;
@PostMapping("decrypt") @PostMapping("decrypt")
public Single<String> decrypt(@RequestBody Map<String,String> body){ public Single<String> decrypt(@RequestBody Map<String,String> body){
return Single.defer(() -> { return Single.defer(() -> {
System.out.println(body); String aesKey = body.getOrDefault("key", defaultAesKey);
return Single.just("hello world"); String aesIv = body.getOrDefault("iv", defaultAesIv);
byte[] content = body.getOrDefault("content","").getBytes();
return Single.fromCallable(() -> {
Optional<byte[]> resulOptional = Aes.decrypt(aesKey, aesIv, content);
return "hello world";
});
}); });
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册