Commit 19dedad5 by yangyang

AES接口提交

parent ababeaed
package com.founder.servicebase.controller;
import com.founder.commonutils.model.newPublicEntity.MapRestResult;
import com.founder.commonutils.util.AesEncryptUtil;
import com.founder.servicebase.logs.OperLog;
import com.founder.servicebase.logs.OperationType;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* 字典控制层
* @author jlt
* @date 2022/03/10/
*/
@RestController
@RequestMapping("Aes")
public class SkAesController {
/**
* 新增字典
*/
@GetMapping("query/{data}")
@ApiOperation(value = "AES加密")
@OperLog(message = "AES加密", operation = OperationType.QUERY)
public MapRestResult save(@PathVariable("data") String data) {
//使用AES-128-CBC加密模式
Date now = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
String today = simpleDateFormat.format(now);
String KEY = "maplogin" + today;
String IV = "map_vues" + today;
try {
data = AesEncryptUtil.encrypt(data, KEY, IV);
System.out.println("数据:" + data);
System.out.println("加密:" + data);
String jiemi = AesEncryptUtil.desEncrypt(data, KEY, IV).trim();
System.out.println("解密:" + jiemi);
} catch (Exception e) {
e.printStackTrace();
return MapRestResult.build(201, "AES-128-CBC加密失败", 1, e);
}
return MapRestResult.build(200, "AES-128-CBC加密模式", 1, "加密:" + data);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment