Actually, decryption is already built-in.
com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty
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;
}
After detecting the format ENC(xxx)
, it will decrypt.
In the configuration file, you only need to add:
spring.datasource.dynamic.datasource.gesoft_pcp.password=ENC(xxxxx)
spring.datasource.dynamic.datasource.gesoft_pcp.public-key=xxxxxx
That's all, there is no more.