// 未分类
DynamicDataSource配置文件密码公钥解密
发布 2021-07-21 · 永久链接
no excerpt about this article
其实已经自带了解密
`com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty`
``` java
private String decrypt(String cipherText) {
if (StringUtils.hasText(cipherText)) {
Matcher matcher = ENC_PATTERN.matcher(cipherText);
if (matcher.find()) {
try {
return CryptoUtils.decrypt(this.publicKey, matcher.group(1));
} catch (Exception var4) {
log.error("DynamicDataSourceProperties.decrypt error ", var4);
}
}
}
return cipherText;
}
```
检测到 `ENC(xxx)`格式后回解密
配置文件上只需要
``` yml
spring.datasource.dynamic.datasource.gesoft_pcp.password=ENC(xxxxx)
spring.datasource.dynamic.datasource.gesoft_pcp.public-key=xxxxxx
```
然后,就没有然后了