http encryption : response encrypt wrapper

This commit is contained in:
haerong22
2021-09-02 14:19:34 +09:00
parent abf70e98f9
commit ce3e4a91a5
7 changed files with 84 additions and 11 deletions

View File

@@ -1,5 +1,8 @@
package com.example.httpencryption.utils;
import com.example.httpencryption.dto.TestDto;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -9,13 +12,19 @@ class AESUtilTest {
AESUtil util = new AESUtil();
@Test
void encryptTest() {
String hello = util.encrypt("hello");
void encryptTest() throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper();
System.out.println("hello = " + hello);
TestDto testDto = new TestDto("kim", 20);
String decrypt = util.decrypt(hello);
String s = objectMapper.writeValueAsString(testDto);
assertEquals("hello", decrypt);
String test = util.encrypt(s);
System.out.println("hello = " + test);
String decrypt = util.decrypt(test);
assertEquals("{\"username\":\"kim\",\"age\":20}", decrypt);
}
}