ํ‹ฐ์Šคํ† ๋ฆฌ ๋ทฐ

๋ฐ˜์‘ํ˜•
 

โœ… [Springboot] Jasypt ์„ค์น˜ ๋ฐ ์„ค์ •

1. Jasypt ์„ค์น˜

์™ธ๋ถ€์— ๊ณต๊ฐœ๋˜๋ฉด ์•ˆ๋˜๋Š” ์ •๋ณด๋“ค์„ ์•”๋ณตํ˜ธํ™” ํ•ด์•ผํ•  ๊ฒฝ์šฐ Jasypt๋ฅผ ์ด์šฉํ•˜์—ฌ ์•”๋ณตํ˜ธํ™”๋ฅผ ์ ์šฉํ•ฉ๋‹ˆ๋‹ค.

 

์šฐ์„  ์•”๋ณตํ˜ธํ™”๋ฅผ ํ•˜๊ธฐ ์œ„ํ•œ Jasypt ๋‹ค์šด

http://www.jasypt.org/download.html

 

Jasypt: Java simplified encryption - Jasypt: Java simplified encryption - Download

Download Jasypt Current version: 1.9.3 (May 25th, 2019) [WHAT'S NEW IN JASYPT 1.9] DOWNLOAD JASYPT (from GitHub) If you are using Maven for building your project, have a look at Jasypt + Maven for details on adding a dependency on Jasypt. Jasypt consists o

www.jasypt.org

์ ๋‹นํ•œ ์œ„์น˜์— ๋‹ค์šด๋กœ๋“œ๋ฅผ ๋ฐ›๊ณ  ์••์ถ•์„ ํ’‰๋‹ˆ๋‹ค.

Jasypt ์••์ถ•ํ‘ผ ๋””๋ ‰ํ† ๋ฆฌ

Jasypt๋ฅผ ์ด์šฉํ•˜์—ฌ ํ‰๋ฌธ์„ ์•”๋ณตํ˜ธํ™”๊ฐ€ ์ž˜๋˜๋Š”์ง€ ํ…Œ์ŠคํŠธ๋ฅผ CMD๋ฅผ ์ด์šฉํ•ด์„œ ํ•ด๋ด…์‹œ๋‹ค

#์‹คํ–‰
./listAlgorithms.sh

์œ„์˜ ๋ช…๋ น์–ด๋กœ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ํ™•์ธ๊ฐ€๋Šฅ

Jasypt๋ฅผ ์ด์šฉํ•ด์„œ CMD๋กœ ์•”ํ˜ธํ™”

//input = ํ‰๋ฌธ, password = ์•”๋ณตํ˜ธํ™”ํ‚ค, algorithm = ์•Œ๊ณ ๋ฆฌ์ฆ˜
./encrypt.sh input="password" password="pwsswordKey" algorithm="PBEWITHMD5ANDDES"

 

output ์•”ํ˜ธํ™”๊ฐ’

Jasypt๋ฅผ ์ด์šฉํ•ด์„œ CMD๋กœ ๋ณตํ˜ธํ™”

./decrypt.sh input="YHMzhZCEOWVX8kKpaGWm3Sc9ovILmGft" password="pwsswordKey" algorithm="PBEWITHMD5ANDDES"

์•”๋ณตํ˜ธํ™”๊ฐ€ ์ž˜ ๋˜๋Š” ๊ฒƒ์„ ํ™•์ธํ–ˆ๋‹ค

์ด์ œ ์•”ํ˜ธํ™”๋œ Output๊ฐ’์œผ๋กœ Spring์— ๋„ฃ๊ณ  ์…‹ํŒ…ํ•ด๋ด…์‹œ๋‹ค

 

Springboot์— Jasypt ์…‹ํŒ…ํ•˜๊ธฐ

Dependency ์„ค์ •

// jasypt
implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.4'

application.yml or properties ์„ค์ •

jasypt:
  encryptor:
    password: passwordKey
    algorithm: PBEWithMD5AndDES
    iv-generator-classname: org.jasypt.iv.NoIvGenerator

spring:
  datasource:
     url: jdbc:oracle:thin:@127.0.0.1:9898:local_db
     type: com.zaxxer.hikari.HikariDataSource
     driver-class-name: oracle.jdbc.OracleDriver
     username: ENC(YHMzhZCEOWVX8kKpaGWm3Sc9ovILmGft)
     password: ENC(YHMzhZCEOWVX8kKpaGWm3Sc9ovILmGft)
     
 /** 
 * ์ฐธ๊ณ 
 **/
 password : ํŒจ์Šค์›Œ๋“œํ‚ค๋ฅผ ๊ธฐ์ž…ํ•ด๋‘์—ˆ๋Š”๋ฐ
 ํ•ด๋‹น๋ถ€๋ถ„์„ ์ˆจ๊ธฐ๊ธฐ์œ„ํ•ด์„œ๋Š” java์‹คํ–‰์‹œ ํ™˜๊ฒฝ๋ณ€์ˆ˜๋กœ ๋„ฃ์–ด์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค
 jasypt.encryptor.password=passwordKey

springboot @annotation์„ค์ •

@EnableEncryptableProperties
@SpringBootApplication
public class TestApplication {
๊ณต์ง€์‚ฌํ•ญ
์ตœ๊ทผ์— ์˜ฌ๋ผ์˜จ ๊ธ€
์ตœ๊ทผ์— ๋‹ฌ๋ฆฐ ๋Œ“๊ธ€
Total
Today
Yesterday
๋งํฌ
ยซ   2024/12   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
๊ธ€ ๋ณด๊ด€ํ•จ
๋ถ„๋ฅ˜ ์ „์ฒด๋ณด๊ธฐ (80)
๐Ÿ“บ Develop (0)
๐ŸŒ‹ Error Fixed (5)
๐Ÿ— Tool (5)
๐Ÿ’ป MacBook M1 (15)
๐Ÿ“ฆ ETC (1)

์ด ํฌ์ŠคํŒ…์€ ์ฟ ํŒก ํŒŒํŠธ๋„ˆ์Šค ํ™œ๋™์˜ ์ผํ™˜์œผ๋กœ, ์ด์— ๋”ฐ๋ฅธ ์ผ์ •์•ก์˜ ์ˆ˜์ˆ˜๋ฃŒ๋ฅผ ์ œ๊ณต๋ฐ›์Šต๋‹ˆ๋‹ค.