개발 이야기
Jasypt - spring properties 암호화
요령도사
2019. 10. 8. 11:05
반응형
- Jasypt download
http://www.jasypt.org/download.html
ReadMe.md 참고
Download distributable: jasypt 1.9.3 (binaries and javadocs)
- Jasypt Encoding/Decoding
@ 인코딩
bin> .\encrypt.bat input="1234" password="[암호키]" algorithm="PBEWITHMD5ANDDES"
----ENVIRONMENT-----------------
Runtime: Oracle Corporation Java HotSpot(TM) 64-Bit Server VM 25.151-b12
----ARGUMENTS-------------------
algorithm: PBEWITHMD5ANDDES
input: 1234
password: [암호키]
----OUTPUT----------------------
7CRKHUxYPSLizO6X/1D96w==
@ 디코딩
bin> .\decrypt.bat input="7CRKHUxYPSLizO6X/1D96w==" password="[암호키]" algorithm="PBEWITHMD5ANDDES"
----ENVIRONMENT-----------------
Runtime: Oracle Corporation Java HotSpot(TM) 64-Bit Server VM 25.151-b12
----ARGUMENTS-------------------
algorithm: PBEWITHMD5ANDDES
input: 7CRKHUxYPSLizO6X/1D96w==
password: [암호키]
----OUTPUT----------------------
1234
- pom.xml
<!-- Jasypt -->
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt-spring31</artifactId>
<version>1.9.2</version>
</dependency>
- context-common.xml
<bean id="stringPbeConfig" class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">
<property name="algorithm" value="PBEWithMD5AndDES" />
<property name="password" value="[암호값]" />
</bean>
<bean id="stringEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
<property name="config" ref="stringPbeConfig" />
</bean>
<bean id="propertyConfigurer" class="org.jasypt.spring3.properties.EncryptablePropertyPlaceholderConfigurer">
<constructor-arg ref="stringEncryptor" />
<property name="locations">
<list>
<value>classpath:/egovframework/property/globals.properties</value>
</list>
</property>
</bean>
- globals.properties : ENC([인코딩 값])
Globals.Password =ENC(7CRKHUxYPSLizO6X/1D96w==)
반응형