Merge branch 'dev'
commit
a12ea0b6ac
@ -0,0 +1,29 @@
|
||||
package com.xit.core.config.support;
|
||||
|
||||
import org.jasypt.encryption.StringEncryptor;
|
||||
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
|
||||
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class JasyptConfig {
|
||||
|
||||
@Bean(name = "jasyptStringEncryptor")
|
||||
public StringEncryptor stringEncryptor() {
|
||||
|
||||
String key = "xit_jasypt_key";
|
||||
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
|
||||
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
|
||||
config.setPassword(key); // 암호화할 때 사용하는 키
|
||||
config.setAlgorithm("PBEWithMD5AndDES"); // 암호화 알고리즘
|
||||
config.setKeyObtentionIterations("1000"); // 반복할 해싱 회수
|
||||
config.setPoolSize("1"); // 인스턴스 pool
|
||||
config.setProviderName("SunJCE");
|
||||
config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator"); // salt 생성 클래스
|
||||
config.setStringOutputType("base64"); //인코딩 방식
|
||||
|
||||
encryptor.setConfig(config);
|
||||
return encryptor;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.xit.core;
|
||||
|
||||
import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
|
||||
@SpringBootTest
|
||||
@ActiveProfiles(value="dev")
|
||||
class JasyptApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
@Test
|
||||
void jasypt() {
|
||||
String url = "jdbc:oracle:thin:@211.119.124.118:1521:bustms";
|
||||
String username = "traffic";
|
||||
String password = "xhdgkq0";
|
||||
|
||||
System.out.println(jasyptEncoding(url));
|
||||
System.out.println(jasyptEncoding(username));
|
||||
System.out.println(jasyptEncoding(password));
|
||||
}
|
||||
|
||||
public String jasyptEncoding(String value) {
|
||||
|
||||
String key = "xit_jasypt_key";
|
||||
StandardPBEStringEncryptor pbeEnc = new StandardPBEStringEncryptor();
|
||||
pbeEnc.setAlgorithm("PBEWithMD5AndDES");
|
||||
pbeEnc.setPassword(key);
|
||||
return pbeEnc.encrypt(value);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue