banner
RustyNail

RustyNail

coder. 【blog】https://rustynail.me 【nostr】wss://ts.relays.world/ wss://relays.world/nostr

Decrypting the password public key in the DynamicDataSource configuration file

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.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.