• 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-03-21 14:15 마이페이지 성능개선을 위해서 이용내역 ajax로 분리 처리함
2024-03-21
.codetogether.ignore
mjon_git
2023-06-12
.gitignore
gitignore 적용
2023-06-12
pom.xml
플러그인 추가 원복
2024-02-16
File name
Commit message
Commit date
java
2024-03-21 14:15 마이페이지 성능개선을 위해서 이용내역 ajax로 분리 처리함
2024-03-21
resources
2024-03-21 14:15 마이페이지 성능개선을 위해서 이용내역 ajax로 분리 처리함
2024-03-21
webapp
2024-03-21 14:15 마이페이지 성능개선을 위해서 이용내역 ajax로 분리 처리함
2024-03-21
File name
Commit message
Commit date
egovframework
mjon_git
2023-06-12
itn
2024-03-21 14:15 마이페이지 성능개선을 위해서 이용내역 ajax로 분리 처리함
2024-03-21
File name
Commit message
Commit date
com
관리자 문자전송 리스트 기본 검색 기간 변경 - 기본 검색 시작일자 한달전에서 하루전으로 변경
2024-01-26
let
2024-03-21 14:15 마이페이지 성능개선을 위해서 이용내역 ajax로 분리 처리함
2024-03-21
web
메인메뉴 및 사이트맵에서 선거 후보자 정보가 없는 경우 선거문자 메뉴가 안보이도록 처리
2024-02-08
File name
Commit message
Commit date
cop
사용자 이용정지인 경우 알림톡 전송, 팩스 전송, 1:1 문의등록 화면 접속 불가처리
2023-11-09
crypto/web
mjon_git
2023-06-12
fax
팩스 back단에서 금액체크
2024-03-15
hangulparser
mjon_git
2023-06-12
kakao
발송결과, 예약문자관리 메뉴 검색일자 지정 - 검색일자가 없는 경우 전날 ~ 금일 기간으로 검색되도록 지정
2024-02-07
komoran
mjon_git
2023-06-12
lett
선택한 그림문자의 우선선위 변경 기능 추가
2023-09-05
mail
휴면회원으로 지정 기준날짜 변경
2023-07-25
main
이준호 문자온 커밋 - IP 받아오는 방식 수정
2023-07-28
mjo
id 로직 주식처리
2024-03-11
module/base
mjon_git
2023-06-12
org
mjon_git
2023-06-12
schdlr/service
2024-03-14 15:21 스케쥴러 트랜잭션 오류 수정
2024-03-14
sec
mjon_git
2023-06-12
solr
mjon_git
2023-06-12
sts
mjon_git
2023-06-12
sym
관리자방문수 관리 쿼리 성능개선, 기간검색 시작일 초기값 설정 추가
2023-09-13
uat
2024-03-21 14:15 마이페이지 성능개선을 위해서 이용내역 ajax로 분리 처리함
2024-03-21
uss
2024-03-20 16:34 마이페이지 최근 발송내역-문자 쿼리 성능개선
2024-03-20
utl
이준호 문자온 커밋 - IP 받아오는 방식 수정
2023-07-28
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
휴면회원 SMS발송 기능 추가 작업중
2023-07-18
File name
Commit message
Commit date
EgovClntInfo.java
이준호 문자온 커밋 - IP 받아오는 방식 수정
2023-07-28
EgovFileScrty.java
mjon_git
2023-06-12
hylee 2023-06-12 f02d3bf 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