# Jasypt 加解密教學
因為專案需要用到將properties的密碼都加密,所以找了這個Jasypt加解密教學
- [Jasypt 教學](https://greddyblogs.gitlab.io/2019/02/27/jasypt/#gsc.tab=0)
然後最新版是3.0.5
- [在Spring Boot微服务使用jasypt-spring-boot-3.0.5的3种算法加解密yml配置文件](https://blog.csdn.net/zhangbeizhen18/article/details/130416581)
或者在服务器的环境变量里配置,进一步提高安全性
打开/etc/profile文件
vim /etc/profile
文件末尾插入
export JASYPT_PASSWORD = G0CvDz7oJn6
编译
source /etc/profile
运行
java -jar -Djasypt.encryptor.password=${JASYPT_PASSWORD} xxx.jar
---
spring boot 在tomcat上面加上jasypt.encryptor.password
[參考網站](https://stackoverflow.com/questions/73620128/tomcat-10-pass-environment-variable-or-property-to-spring-boot-context)
The solution in the end was to create the file setenv.bat in ${TOMCAT_HOME}/bin/setenv.bat
Following the approach: How to pass the -D additional parameter while starting tomcat?
The content of setenv.bat:
```
set CATALINA_OPTS=%CATALINA_OPTS -Djasypt.encryptor.password="HywebBSS1qaz@WSX"
```
或是
```
export CATALINA_OPTS="-Djasypt.encryptor.password=HywebBSS1qaz@WSX"
```