• 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
Merge branch 'master' of http://hylee@vcs.iten.co.kr:9999/hylee/mjon_git into advc
2024-09-10
.codetogether.ignore
mjon_git
2023-06-12
.gitignore
gitignore 적용
2023-06-12
pom.xml
롬복 추가 , [사용자] 결제관리 > 요금 사용내역 ==> 사용금액 표시 방법 변경 완료
2024-07-09
File name
Commit message
Commit date
java
Merge branch 'master' of http://hylee@vcs.iten.co.kr:9999/hylee/mjon_git into advc
2024-09-10
resources
Merge branch 'master' of http://hylee@vcs.iten.co.kr:9999/hylee/mjon_git into advc
2024-09-10
webapp
Merge branch 'master' of http://hylee@vcs.iten.co.kr:9999/hylee/mjon_git into advc
2024-09-10
File name
Commit message
Commit date
egovframework
mjon_git
2023-06-12
itn
Merge branch 'master' of http://hylee@vcs.iten.co.kr:9999/hylee/mjon_git into advc
2024-09-10
File name
Commit message
Commit date
com
Merge branch 'master' of http://hylee@vcs.iten.co.kr:9999/hylee/mjon_git into advc
2024-09-10
let
Merge branch 'master' of http://hylee@vcs.iten.co.kr:9999/hylee/mjon_git into advc
2024-09-10
web
메인메뉴 및 사이트맵에서 선거 후보자 정보가 없는 경우 선거문자 메뉴가 안보이도록 처리
2024-02-08
File name
Commit message
Commit date
cop
사용자 이용정지인 경우 알림톡 전송, 팩스 전송, 1:1 문의등록 화면 접속 불가처리
2023-11-09
crypto/web
mjon_git
2023-06-12
fax
주소록 수정중
2024-09-09
hangulparser
mjon_git
2023-06-12
kakao
Merge branch 'master' of http://hylee@vcs.iten.co.kr:9999/hylee/mjon_git into advc
2024-09-10
komoran
mjon_git
2023-06-12
lett
선택한 그림문자의 우선선위 변경 기능 추가
2023-09-05
mail
Merge branch 'master' into hylee
2024-08-02
main
이준호 문자온 커밋 - IP 받아오는 방식 수정
2023-07-28
mjo
Merge branch 'master' of http://hylee@vcs.iten.co.kr:9999/hylee/mjon_git into advc
2024-09-10
module/base
금액 포인트 class 수정
2024-07-08
org
mjon_git
2023-06-12
schdlr/service
IP 차단 관련 오류 확인전
2024-04-09
sec
mjon_git
2023-06-12
solr
mjon_git
2023-06-12
sts
mjon_git
2023-06-12
sym
야간 스미싱 알림기능 개발 완료
2024-08-20
uat
Merge branch 'master' of http://hylee@vcs.iten.co.kr:9999/hylee/mjon_git into advc
2024-09-10
uss
Merge branch 'master' of http://hylee@vcs.iten.co.kr:9999/hylee/mjon_git into advc
2024-09-10
utl
문자온 대표번호 변경으로 인한 15518011 으로 변경
2024-07-31
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
문자온 대표번호 변경으로 인한 15518011 으로 변경
2024-07-31
File name
Commit message
Commit date
EgovClntInfo.java
이준호 문자온 커밋 - IP 받아오는 방식 수정
2023-07-28
EgovFileScrty.java
mjon_git
2023-06-12
hylee 2023-06-12 60ad230 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