Skip to content

Commit

Permalink
[#23] feat: Jasypt 테스트 클래스 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
hsik0225 committed May 26, 2020
1 parent 058f818 commit 08a877d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.codesquad.airbnb.infra.config;

import lombok.extern.slf4j.Slf4j;
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
import org.jasypt.salt.StringFixedSaltGenerator;

import java.util.Scanner;

public class JasyptEncryptor {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

String password = System.getenv("JASYPT_PASSWORD");

PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
SimpleStringPBEConfig config = new SimpleStringPBEConfig();

config.setPassword(password); // 암호화에 사용할 키
config.setAlgorithm("PBEWithMD5AndDES"); //사용할 알고리즘
config.setKeyObtentionIterations("1000");
config.setPoolSize("1");
config.setSaltGenerator(new StringFixedSaltGenerator("FixedSalt"));
config.setStringOutputType("base64");
encryptor.setConfig(config);

while(true) {
System.out.println("암호화를 그만하려면 x를 입력해주세요!");

String str = sc.nextLine();

if(str.equals("x")) {
break;
}

String encStr = encryptor.encrypt(str);
String decStr = encryptor.decrypt(encStr);

System.out.println("str = " + str);
System.out.println("encStr = " + encStr);
System.out.println("decStr = " + decStr);
}
}
}
12 changes: 6 additions & 6 deletions BE/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ spring:
profiles: local

datasource:
url: ENC(BDec5XAPjm1PZVU9+3IkeWtJvf50AWsMLUFjCNIEinUcCnIogDjW3DtGHkS6ztfV16vWVa6io5JUL/5LNJuGBB+EYttfYqf/f2nBMNPcMzo=)
username: ENC(/DEaWdfpObo=)
password: ENC(E9hxauGe3BgotYjCaS4O+g==)
url: ENC(yAAKfSsndK8iJjvfYMsK/+Lrb9vQfJ//0JQ4sz1ZF5H2ebBOzWYY2glEFb/fjAqg+gVzvRQTd8cfOL3a/rDKl7LLY0rRQ3B+L6cQDN/p6QY=)
username: ENC(MXeQAanxppo=)
password: ENC(QQErW0P9WFtyBoyisL9XAw==)

---
spring:
profiles: real_server

datasource:
url: ENC(BDec5XAPjm1PZVU9+3IkeWtJvf50AWsMLUFjCNIEinUcCnIogDjW3DtGHkS6ztfV16vWVa6io5JUL/5LNJuGBB+EYttfYqf/f2nBMNPcMzo=)
username: ENC(SGzp40WhXRiCGoSbBkM1zw==)
password: ENC(E9hxauGe3BgotYjCaS4O+g==)
url: ENC(yAAKfSsndK8iJjvfYMsK/+Lrb9vQfJ//0JQ4sz1ZF5H2ebBOzWYY2glEFb/fjAqg+gVzvRQTd8cfOL3a/rDKl7LLY0rRQ3B+L6cQDN/p6QY=)
username: ENC(60LPIowemN6kQSuE99JQ3w==)
password: ENC(QQErW0P9WFtyBoyisL9XAw==)

0 comments on commit 08a877d

Please sign in to comment.