• Y
  • List All
  • Feedback
    • This Project
    • All Projects
Profile Account settings Log out
  • Favorite
  • Project
  • All
Loading...
  • Log in
  • Sign up
chominsoo4245 / mjon_git star
Forked from hylee / mjon_git
  • Project homeH
  • CodeC
  • IssueI
  • Pull requestP
  • Review R
  • MilestoneM
  • BoardB
  • Files
  • Commit
  • Branches
mjon_gitsrcmainjavaitnletutlsimserviceEgovFileScrty.java
Download as .zip file
File name
Commit message
Commit date
DATABASE
mjon_git
2023-06-12
src/main
문자발송 - 번호추가 안내문구 수정 / 발송결과에 단문 장문 구분 수정
2024-12-09
.codetogether.ignore
mjon_git
2023-06-12
.gitignore
gitignore 적용
2023-06-12
pom.xml
문자전송개선 테스트
2024-11-27
File name
Commit message
Commit date
java
문자발송 - 번호추가 안내문구 수정 / 발송결과에 단문 장문 구분 수정
2024-12-09
resources
팩스 주소록 진행중
2024-12-09
webapp
문자발송 - 번호추가 안내문구 수정 / 발송결과에 단문 장문 구분 수정
2024-12-09
File name
Commit message
Commit date
egovframework
custom idgen 수정
2024-11-27
itn
문자발송 - 번호추가 안내문구 수정 / 발송결과에 단문 장문 구분 수정
2024-12-09
File name
Commit message
Commit date
com
문자 개별단가별 그룹화하여 분리 발송
2024-12-06
let
문자발송 - 번호추가 안내문구 수정 / 발송결과에 단문 장문 구분 수정
2024-12-09
web
스케줄러 500개로 줄임
2024-11-06
File name
Commit message
Commit date
cop
이용약관 및 개인정보 내용 수정
2024-10-28
crypto/web
mjon_git
2023-06-12
fax
팩스 주소록 삭제기능 수정중
2024-11-11
hangulparser
mjon_git
2023-06-12
kakao
Merge branch 'master' of http://hylee@vcs.iten.co.kr:9999/hylee/mjon_git into advc
2024-11-14
komoran
mjon_git
2023-06-12
lett
선택한 그림문자의 우선선위 변경 기능 추가
2023-09-05
mail
문자발송로직 impl 화 완료 -> 리펙토링 진행 중
2024-09-27
main
이준호 문자온 커밋 - IP 받아오는 방식 수정
2023-07-28
mjo
문자발송 - 번호추가 안내문구 수정 / 발송결과에 단문 장문 구분 수정
2024-12-09
module/base
문자전송개선 테스트
2024-11-27
org
mjon_git
2023-06-12
schdlr/service
Merge branch 'master' of http://hylee@vcs.iten.co.kr:9999/hylee/mjon_git into advc
2024-11-14
sec
mjon_git
2023-06-12
solr
mjon_git
2023-06-12
sts
mjon_git
2023-06-12
sym
Merge branch 'master' of http://hylee@vcs.iten.co.kr:9999/hylee/mjon_git into advc
2024-11-14
uat
Merge branch 'master' of http://hylee@vcs.iten.co.kr:9999/hylee/mjon_git into advc
2024-09-10
uss
slack 개발 운영 분기
2024-12-04
utl
회원 이메일 발송 건수 15분 단위로 기존 200건 -> 500건으로 변경
2024-10-25
File name
Commit message
Commit date
fcc/service
mjon_git
2023-06-12
log4j
mjon_git
2023-06-12
sim/service
이준호 문자온 커밋 - IP 받아오는 방식 수정
2023-07-28
user/service
회원 이메일 발송 건수 15분 단위로 기존 200건 -> 500건으로 변경
2024-10-25
File name
Commit message
Commit date
EgovClntInfo.java
이준호 문자온 커밋 - IP 받아오는 방식 수정
2023-07-28
EgovFileScrty.java
mjon_git
2023-06-12
hylee 2023-06-12 4e2daf5 mjon_git UNIX
Raw Open in browser Change history
package itn.let.utl.sim.service; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.security.MessageDigest; import org.apache.commons.codec.binary.Base64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Base64인코딩/디코딩 방식을 이용한 데이터를 암호화/복호화하는 Business Interface class * @author 공통서비스개발팀 박지욱 * @since 2009.01.19 * @version 1.0 * @see * * <pre> * << 개정이력(Modification Information) >> * * 수정일 수정자 수정내용 * ------- -------- --------------------------- * 2009.01.19 박지욱 최초 생성 * 2011.08.31 JJY 경량환경 템플릿 커스터마이징버전 생성 * * </pre> */ public class EgovFileScrty { private static final Logger LOGGER = LoggerFactory.getLogger(EgovFileScrty.class); // 파일구분자 static final char FILE_SEPARATOR = File.separatorChar; // 버퍼사이즈 static final int BUFFER_SIZE = 1024; /** * 파일을 암호화하는 기능 * * @param String source 암호화할 파일 * @param String target 암호화된 파일 * @return boolean result 암호화여부 True/False * @exception Exception */ public static boolean encryptFile(String source, String target) throws Exception { // 암호화 여부 boolean result = false; String sourceFile = source.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR); String targetFile = target.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR); File srcFile = new File(sourceFile); BufferedInputStream input = null; BufferedOutputStream output = null; byte[] buffer = new byte[BUFFER_SIZE]; try { if (srcFile.exists() && srcFile.isFile()) { input = new BufferedInputStream(new FileInputStream(srcFile)); output = new BufferedOutputStream(new FileOutputStream(targetFile)); int length = 0; while ((length = input.read(buffer)) >= 0) { byte[] data = new byte[length]; System.arraycopy(buffer, 0, data, 0, length); output.write(encodeBinary(data).getBytes()); output.write(System.getProperty("line.separator").getBytes()); } result = true; } } finally { if (input != null) { try { input.close(); } catch (Exception ignore) { LOGGER.debug("IGNORE: {}", ignore); } } if (output != null) { try { output.close(); } catch (Exception ignore) { LOGGER.debug("IGNORE: {}", ignore); } } } return result; } /** * 파일을 복호화하는 기능 * * @param String source 복호화할 파일 * @param String target 복호화된 파일 * @return boolean result 복호화여부 True/False * @exception Exception */ public static boolean decryptFile(String source, String target) throws Exception { // 복호화 여부 boolean result = false; String sourceFile = source.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR); String targetFile = target.replace('\\', FILE_SEPARATOR).replace('/', FILE_SEPARATOR); File srcFile = new File(sourceFile); BufferedReader input = null; BufferedOutputStream output = null; //byte[] buffer = new byte[BUFFER_SIZE]; String line = null; try { if (srcFile.exists() && srcFile.isFile()) { input = new BufferedReader(new InputStreamReader(new FileInputStream(srcFile))); output = new BufferedOutputStream(new FileOutputStream(targetFile)); while ((line = input.readLine()) != null) { byte[] data = line.getBytes(); output.write(decodeBinary(new String(data))); } result = true; } } finally { if (input != null) { try { input.close(); } catch (Exception ignore) { LOGGER.debug("IGNORE: {}", ignore); } } if (output != null) { try { output.close(); } catch (Exception ignore) { LOGGER.debug("IGNORE: {}", ignore); } } } return result; } /** * 데이터를 암호화하는 기능 * * @param byte[] data 암호화할 데이터 * @return String result 암호화된 데이터 * @exception Exception */ public static String encodeBinary(byte[] data) throws Exception { if (data == null) { return ""; } return new String(Base64.encodeBase64(data)); } /** * 데이터를 암호화하는 기능 * * @param String data 암호화할 데이터 * @return String result 암호화된 데이터 * @exception Exception */ public static String encode(String data) throws Exception { return encodeBinary(data.getBytes()); } /** * 데이터를 복호화하는 기능 * * @param String data 복호화할 데이터 * @return String result 복호화된 데이터 * @exception Exception */ public static byte[] decodeBinary(String data) throws Exception { return Base64.decodeBase64(data.getBytes()); } /** * 데이터를 복호화하는 기능 * * @param String data 복호화할 데이터 * @return String result 복호화된 데이터 * @exception Exception */ public static String decode(String data) throws Exception { return new String(decodeBinary(data)); } /** * 비밀번호를 암호화하는 기능(복호화가 되면 안되므로 SHA-256 인코딩 방식 적용). * * deprecated : 보안 강화를 위하여 salt로 ID를 지정하는 encryptPassword(password, id) 사용 * * @param String data 암호화할 비밀번호 * @return String result 암호화된 비밀번호 * @exception Exception */ @Deprecated public static String encryptPassword(String data) throws Exception { if (data == null) { return ""; } byte[] plainText = null; // 평문 byte[] hashValue = null; // 해쉬값 plainText = data.getBytes(); MessageDigest md = MessageDigest.getInstance("SHA-256"); // 변경 시 기존 hash 값에 검증 불가.. => deprecated 시키고 유지 /* // Random 방식의 salt 추가 SecureRandom ng = new SecureRandom(); byte[] randomBytes = new byte[16]; ng.nextBytes(randomBytes); md.reset(); md.update(randomBytes); */ hashValue = md.digest(plainText); /* BASE64Encoder encoder = new BASE64Encoder(); return encoder.encode(hashValue); */ return new String(Base64.encodeBase64(hashValue)); } /** * 비밀번호를 암호화하는 기능(복호화가 되면 안되므로 SHA-256 인코딩 방식 적용) * * @param password 암호화될 패스워드 * @param id salt로 사용될 사용자 ID 지정 * @return * @throws Exception */ public static String encryptPassword(String password, String id) throws Exception { if (password == null) { return ""; } byte[] hashValue = null; // 해쉬값 MessageDigest md = MessageDigest.getInstance("SHA-256"); md.reset(); md.update(id.getBytes()); hashValue = md.digest(password.getBytes()); return new String(Base64.encodeBase64(hashValue)); } /** * 비밀번호를 암호화하는 기능(복호화가 되면 안되므로 SHA-256 인코딩 방식 적용) * @param data 암호화할 비밀번호 * @param salt Salt * @return 암호화된 비밀번호 * @throws Exception */ public static String encryptPassword(String data, byte[] salt) throws Exception { if (data == null) { return ""; } byte[] hashValue = null; // 해쉬값 MessageDigest md = MessageDigest.getInstance("SHA-256"); md.reset(); md.update(salt); hashValue = md.digest(data.getBytes()); return new String(Base64.encodeBase64(hashValue)); } /** * 비밀번호를 암호화된 패스워드 검증(salt가 사용된 경우만 적용). * * @param data 원 패스워드 * @param encoded 해쉬처리된 패스워드(Base64 인코딩) * @return * @throws Exception */ public static boolean checkPassword(String data, String encoded, byte[] salt) throws Exception { byte[] hashValue = null; // 해쉬값 MessageDigest md = MessageDigest.getInstance("SHA-256"); md.reset(); md.update(salt); hashValue = md.digest(data.getBytes()); return MessageDigest.isEqual(hashValue, Base64.decodeBase64(encoded.getBytes())); } }

          
        
    
    
Copyright Yona authors & © NAVER Corp. & NAVER LABS Supported by NAVER CLOUD PLATFORM

or
Sign in with github login with Google Sign in with Google
Reset password | Sign up