Get史上最优雅加密方式!没有之一
https://www.jianshu.com/p/64ceda636e81
spring boot使用jasypt加密原理解析
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
jasypt组件能够解密任何位置的解密套件
因为它本质扫描全部environment下的全部DataSources的key,value,如果value是ENC(密文),则会使用注入的解密类解密。
application.yaml新增配置
cloud:
sk: ENC(AAAAAgAAAAAAAAAFAAAAAgAAAAemTVNASXWCKkSSa9mh6nnob1/YCybIongIJE9g3R0gIgAAAAAAAAAAAAAAMBlx0Eh3mK43HUG+9m76ZyrMsGy8uLK9e7ldbmWMlDnstvy8ccGvQKG24SCdHwlfRQ==)
代码使用:
@Value("${cloud.sk}")
private String sk;
System.out.println("cloud.ak---" + sk);
//cloud.ak---3822905103e749b48355caa2b188424d