반응형
ARIA는 국내서 개발한 대칭키 암호화 기법이다.
암호화를 구현하기위한 파일 다운로드
- 전자정부프레임워크 홈페이지에서 egovframework.rte.fdl.crypto-?.?.?.jar 파일 다운로드
- jasypt-?.?.?.jar 파일 다운로드
소스작성
- context 설정
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 | <?xml version ="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> <bean id="passwordEncoder" class="egovframework.rte.fdl.cryptography.EgovPasswordEncoder"> <property name = "algorithm" value = "SHA-256" /> <property name = "hashedPassword" value = "sha256으로 암호화한 아리아 패스워드 기입" /> </bean> <bean id = "ARIACryptoService" class = "egovframework.rte.fdl.cryptography.impl.EgovARIACryptoServiceImpl"> <property name = "passwordEncoder" ref = "passwordEncoder" /> <property name = "blockSize" value = "1025" /> </bean> <bean id = "digestService" class = "egovframework.rte.fdl.cryptography.impl.EgovDigestServiceImpl"> <property name = "algorithm" value = "SHA-256" /> <property name = "plainDigest" value = "false" /> </bean> <bean id = "generalCryptoService" class = "egovframework.rte.fdl.cryptography.impl.EgovGeneralCryptoServiceImpl"> <property name = "passwordEncoder" ref = "passwordEncoder" /> <property name = "algorithm" value = "PBEWithSHA1AndDESede" /> <property name = "blockSize" value = "1024" /> </bean> | cs |
- 암호화
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import egovframework.rte.fdl.cryptography.EgovCryptoService; import egovframework.rte.fdl.cryptography.EgovPasswordEncoder; @Resource(name = "ARIACryptoService") private EgovCryptoService egovCryptoService; @Resource(name = "passwordEncoder") private EgovPasswordEncoder passwordEncoder; String pw = "aria1234"; //아리아 비밀번호 설정 String content = "test" //암호화할 내용 byte [] byteContent = content.getBytes("UTF-8"); //암호화시키려면 String -> Byte 로 byte [] encrypt = egovCryptoService.encrypt(byteContent,pw); //암호화 BASE64 base64 = new BASE64(); String encrypted = base64.encode(encrypt); //base64로 스트링 형변환 model.addAttribute("encrypted",encrypted); | cs |
- 복호화
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import egovframework.rte.fdl.cryptography.EgovCryptoService; import egovframework.rte.fdl.cryptography.EgovPasswordEncoder; @Resource(name = "ARIACryptoService") private EgovCryptoService egovCryptoService; @Resource(name = "passwordEncoder") private EgovPasswordEncoder passwordEncoder; String pw = "aria1234"; //아리아 비밀번호 설정 BASE64 base64 = new BASE64(); String param = request.getParameter("encrypted"); byte [] decrypt = base64.decode(param); //String -> Byte 로 디코드 byte [] decrypted = egovCryptoService.decrypt(decrypt,pw); //복호화 String result = new String(decrypted,"UTF-8"); //최종 결과 | cs |
반응형
'Web Development > Web Vulnerability' 카테고리의 다른 글
세션 고정 (0) | 2020.12.15 |
---|---|
웹취약점 대비 톰캣 에러페이지 설정 (0) | 2017.06.16 |