http encryption : response encrypt wrapper
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user