Springboot 使用 jasypt 需要注意的一个小地方

配置文件敏感信息加解密时候,jasypt 比较实用,但需要注意使用对称的 iv-generator-classname;因为这里存在一个小坑,不同版本 jasypt 的默认 iv-generator-classname 不同,解密失败,从而导致程序启动失败。
旧版本默认值

新版本默认值

如果 springboot 中使用如下配置,会导致这种匹配出现可能性比较大
复制代码
建议指定 salt-generator-classname 和 iv-generator-classname
复制代码
加密的时候,建议也要指定对应 salt-generator-classname 和 iv-generator-classname
写法一:

写法二:
复制代码
官方说明

官方资料
https://github.com/ulisesbocchio/jasypt-spring-boot
jasypt 官网http://www.jasypt.org/cli.html
版权声明: 本文为 InfoQ 作者【Sky彬】的原创文章。
原文链接:【http://xie.infoq.cn/article/50de356018ca4d98453f75a3e】。
本文遵守【CC-BY 4.0】协议,转载请保留原文出处及本版权声明。
评论