1+ package com .kernelsquare .core .config ;
2+
3+ import com .ulisesbocchio .jasyptspringboot .annotation .EnableEncryptableProperties ;
4+ import org .jasypt .encryption .StringEncryptor ;
5+ import org .jasypt .encryption .pbe .PooledPBEStringEncryptor ;
6+ import org .jasypt .encryption .pbe .config .SimpleStringPBEConfig ;
7+ import org .springframework .beans .factory .annotation .Value ;
8+ import org .springframework .context .annotation .Bean ;
9+ import org .springframework .context .annotation .Configuration ;
10+
11+ @ Configuration
12+ @ EnableEncryptableProperties
13+ public class JasyptConfig {
14+ @ Value ("${jasypt.password}" )
15+ private String password ;
16+
17+ @ Bean ("jasyptEncryptorAES" )
18+ public StringEncryptor stringEncryptor () {
19+ PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor ();
20+ SimpleStringPBEConfig config = new SimpleStringPBEConfig ();
21+ config .setPassword (password );
22+ config .setAlgorithm ("PBEWITHHMACSHA512ANDAES_256" ); // 알고리즘
23+ config .setKeyObtentionIterations ("1000" ); // 반복할 해싱 횟수
24+ config .setPoolSize ("1" ); // 인스턴스 pool
25+ config .setProviderName ("SunJCE" ); // 기본 암호화 제공자
26+ config .setSaltGeneratorClassName ("org.jasypt.salt.RandomSaltGenerator" ); // 기본 salt 생성 클래스
27+ config .setIvGeneratorClassName ("org.jasypt.iv.RandomIvGenerator" ); // 랜덤 초기화 벡터
28+ config .setStringOutputType ("base64" ); //인코딩 방식
29+ encryptor .setConfig (config );
30+ return encryptor ;
31+ }
32+ }
0 commit comments