diff --git a/src/main/java/cokr/xit/base/crypto/bean/ARIA.java b/src/main/java/cokr/xit/base/crypto/bean/ARIA.java index aff71c5..b9d0e22 100644 --- a/src/main/java/cokr/xit/base/crypto/bean/ARIA.java +++ b/src/main/java/cokr/xit/base/crypto/bean/ARIA.java @@ -13,6 +13,7 @@ import cokr.xit.base.crypto.Cryptography; public class ARIA extends Cryptography { private String key, + hashedPassword, algorithm; private int blockSize; @@ -39,6 +40,21 @@ public class ARIA extends Cryptography { return this; } + /**비밀번호 해시값을 반환한다. + * @return 비밀번호 해시값 + */ + public String getHashedPassword() { + return hashedPassword; + } + + /**비밀번호 해시값을 설정한다. + * @param hashedPassword 비밀번호 해시값 + */ + public ARIA setHashedPassword(String hashedPassword) { + this.hashedPassword = hashedPassword; + return this; + } + /**알고리즘을 반환한다. 디폴트는 SHA-256. * @return 알고리즘 */ @@ -71,17 +87,20 @@ public class ARIA extends Cryptography { return this; } + public byte[] encrypt(byte[] plain) { + return service().encrypt(plain, key); + } + @Override protected String doEncrypt(String plain) { - byte[] bytes = service().encrypt(plain.getBytes(), key); + byte[] bytes = encrypt(plain.getBytes()); return Base64.getEncoder().encodeToString(bytes); } private EgovPasswordEncoder passwordEncoder() { if (passwordEncoder == null) { passwordEncoder = new EgovPasswordEncoder(); - String hashed = passwordEncoder.encryptPassword(getKey()); - passwordEncoder.setHashedPassword(hashed); + passwordEncoder.setHashedPassword(ifEmpty(hashedPassword, hashedPassword = passwordEncoder.encryptPassword(getKey()))); passwordEncoder.setAlgorithm(getAlgorithm()); } return passwordEncoder; @@ -96,10 +115,14 @@ public class ARIA extends Cryptography { return aria; } + public byte[] decrypt(byte[] encrypted) { + return service().decrypt(encrypted, key); + } + @Override protected String doDecrypt(String encrypted) { byte[] bytes = Base64.getDecoder().decode(encrypted); - return new String(service().decrypt(bytes, key)); + return new String(decrypt(bytes)); } /**현재 설정상태를 비운다. diff --git a/src/main/resources/xit-crypto.conf b/src/main/resources/xit-crypto.conf index 592afc6..9faf127 100644 --- a/src/main/resources/xit-crypto.conf +++ b/src/main/resources/xit-crypto.conf @@ -4,6 +4,7 @@ "class": "cokr.xit.base.crypto.bean.ARIA", "settings": { "key": "Copyright (c) 2015 - (주)엑스아이티", + // "hashedPassword": "", // 지정하지 않으면 key로 생성 "algorithm": "SHA-256", "blockSize": 1024 }