데이터 암호화
의존성 주입(DI, Dependency Injection) 사용 방법
crypto:
secret:
key: X2BEE_Application_DATA_SecretKeypackage com.x2bee.api.display;
import com.x2bee.common.base.util.CryptoUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.util.Assert;
@SpringBootTest
@AutoConfigureMockMvc
@Slf4j
class CryptoUtilTest1 {
private CryptoUtil cryptoUtil;
@Autowired
public ApiTest(final CryptoUtil cryptoUtil) {
Assert.notNull(cryptoUtil, "CryptoUtil can't be null");
this.cryptoUtil = cryptoUtil;
}
@Test
public void test1() throws Exception {
log.info("------------------------------------- test1 START ----------------------------------------------------------");
String value = cryptoUtil.encodeBcrypt("가나다");
log.info(value);
Boolean value2 = cryptoUtil.matchesBcrypt("가나다1", value);
log.info("value2 : " + value2);
Boolean value3 = cryptoUtil.matchesBcrypt("가나다", value);
log.info("value3 : " + value3);
String value4 = cryptoUtil.encodeAes("가나다");
log.info(value4);
String value5 = cryptoUtil.decodeAes(value4);
log.info(value5);
log.info("------------------------------------- test1 END ----------------------------------------------------------");
}
}싱글톤 패턴 사용 방법
@Encrypt 커스텀 어노테이션 사용
@Convert(converter = JpaEncryptor.class) 어노테이션 사용
사용 예시 (EncryptUtils)
마지막 업데이트