The most elegant encryption method in Get history! none of them
https://www.jianshu.com/p/64ceda636e81
Spring boot uses jasypt encryption principle analysis
https://blog.csdn.net/u013905744/article/details/86508236
ctrl+alt+h
com.ulisesbocchio.jasyptspringboot.resolver.DefaultPropertyResolver#resolvePropertyValue
EncryptableEnvironment.maybeDecrypt(String) (com.ulisesbocchio.jasyptspringboot.environment)
DefaultLazyPropertyResolver.resolvePropertyValue(String) (com.ulisesbocchio.jasyptspringboot.resolver)
EncryptableEnvironment.maybeDecrypt(String) (com.ulisesbocchio.jasyptspringboot.environment)
DefaultLazyPropertyResolver.resolvePropertyValue(String) (com.ulisesbocchio.jasyptspringboot.resolver)
EncryptablePropertySource.getProperty(EncryptablePropertyResolver, EncryptablePropertyFilter, PropertySource<T>, String) (com.ulisesbocchio.jasyptspringboot)
CachingDelegateEncryptablePropertySource.getProperty(String) (com.ulisesbocchio.jasyptspringboot.caching)
Descriptor in InvalidConfigurationPropertyValueFailureAnalyzer.get(PropertySource<?>, String) (org.springframework.boot.diagnostics.analyzer)
EncryptablePropertySourceMethodInterceptor.invoke(MethodInvocation) (com.ulisesbocchio.jasyptspringboot.aop)
SpringIterableConfigurationPropertySource.getConfigurationProperty(ConfigurationPropertyName) (org.springframework.boot.context.properties.source)
PropertySourcesPlaceholdersResolver.resolvePlaceholder(String) (org.springframework.boot.context.properties.bind)
SpringConfigurationPropertySource.getConfigurationProperty(ConfigurationPropertyName) (org.springframework.boot.context.properties.source)
EncryptableMapPropertySourceWrapper.getProperty(String) (com.ulisesbocchio.jasyptspringboot.wrapper)
Enum constant 'KUBERNETES' in 'CloudPlatform'.isAutoDetected(EnumerablePropertySource<?>) (org.springframework.boot.cloud)
CompositePropertySource.getProperty(String) (org.springframework.core.env)
EncryptablePropertySource.getProperty(EncryptablePropertyResolver, EncryptablePropertyFilter, PropertySource<T>, String) (com.ulisesbocchio.jasyptspringboot)
EncryptablePropertySourceWrapper.getProperty(String) (com.ulisesbocchio.jasyptspringboot.wrapper)
SystemEnvironmentPropertySource.containsProperty(String) (org.springframework.core.env)
FilteredPropertySource.getProperty(String) (org.springframework.boot.context.config)
PropertySource.containsProperty(String)(2 usages) (org.springframework.core.env)
PropertySourcesPropertyResolver.getProperty(String, Class<T>, boolean) (org.springframework.core.env)
JsonPropertyValue in SpringApplicationJsonEnvironmentPostProcessor.get(PropertySource<?>) (org.springframework.boot.env)
EncryptableEnumerablePropertySourceWrapper.getProperty(String) (com.ulisesbocchio.jasyptspringboot.wrapper)
EncryptablePropertySource.getProperty(EncryptablePropertyResolver, EncryptablePropertyFilter, PropertySource<T>, String) (com.ulisesbocchio.jasyptspringboot)
代码集成请参考:
https://github.com/heheliu321/itcast-base-root/tree/itcast-base-root The
jasypt component can decrypt decryption kits in any location
because it essentially scans the keys and values of all DataSources under all environments. If the value is ENC (ciphertext) will be decrypted using the injected decryption class.
Application.yaml new configuration
cloud:
sk: ENC(AAAAAgAAAAAAAAAFAAAAAgAAAAemTVNASXWCKkSSa9mh6nnob1/YCybIongIJE9g3R0gIgAAAAAAAAAAAAAAMBlx0Eh3mK43HUG+9m76ZyrMsGy8uLK9e7ldbmWMlDnstvy8ccGvQKG24SCdHwlfRQ==)
Code usage:
@Value("${cloud.sk}")
private String sk;
System.out.println("cloud.ak---" + sk);
//cloud.ak---3822905103e749b48355caa2b188424d