Config Server 加解密依賴JDK的JCE。 JDK8的下載地址:html
配置config serve encrypt.key=foojava
使用config server 提供的加解密接口生成密文git
curl localhost:4001/encrypt -d lengleng
密文
複製代碼
spring:
datasource:
password: '{ciper}密文'
xxx: '{ciper}密文'
複製代碼
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>1.16</version>
</dependency>
複製代碼
jasypt:
encryptor:
password: foo #根密碼
複製代碼
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = PigAdminApplication.class)
public class PigAdminApplicationTest {
@Autowired
private StringEncryptor stringEncryptor;
@Test
public void testEnvironmentProperties() {
System.out.println(stringEncryptor.encrypt("lengleng"));
}
}
複製代碼
spring:
datasource:
password: ENC(密文)
xxx: ENC(密文)
複製代碼
Key | Required | |
jasypt.encryptor.password | True | 根密碼 |
jasypt.encryptor.algorithm | False | PBEWithMD5AndDES |
jasypt.encryptor.keyObtentionIterations | False | 1000 |
jasypt.encryptor.poolSize | False | 1 |
jasypt.encryptor.providerName | False | SunJCE |
jasypt.encryptor.saltGeneratorClassname | False | org.jasypt.salt.RandomSaltGenerator |
jasypt.encryptor.stringOutputType | False | base64 |
jasypt.encryptor.proxyPropertySources | False | false |