ARIA: hashedPassword 설정 추가

master
mjkhan21 10 months ago
parent c5b72e1160
commit c3ab91c47c

@ -13,6 +13,7 @@ import cokr.xit.base.crypto.Cryptography;
public class ARIA extends Cryptography { public class ARIA extends Cryptography {
private String private String
key, key,
hashedPassword,
algorithm; algorithm;
private int blockSize; private int blockSize;
@ -39,6 +40,21 @@ public class ARIA extends Cryptography {
return this; return this;
} }
/** .
* @return
*/
public String getHashedPassword() {
return hashedPassword;
}
/** .
* @param hashedPassword
*/
public ARIA setHashedPassword(String hashedPassword) {
this.hashedPassword = hashedPassword;
return this;
}
/** . SHA-256. /** . SHA-256.
* @return * @return
*/ */
@ -71,17 +87,20 @@ public class ARIA extends Cryptography {
return this; return this;
} }
public byte[] encrypt(byte[] plain) {
return service().encrypt(plain, key);
}
@Override @Override
protected String doEncrypt(String plain) { protected String doEncrypt(String plain) {
byte[] bytes = service().encrypt(plain.getBytes(), key); byte[] bytes = encrypt(plain.getBytes());
return Base64.getEncoder().encodeToString(bytes); return Base64.getEncoder().encodeToString(bytes);
} }
private EgovPasswordEncoder passwordEncoder() { private EgovPasswordEncoder passwordEncoder() {
if (passwordEncoder == null) { if (passwordEncoder == null) {
passwordEncoder = new EgovPasswordEncoder(); passwordEncoder = new EgovPasswordEncoder();
String hashed = passwordEncoder.encryptPassword(getKey()); passwordEncoder.setHashedPassword(ifEmpty(hashedPassword, hashedPassword = passwordEncoder.encryptPassword(getKey())));
passwordEncoder.setHashedPassword(hashed);
passwordEncoder.setAlgorithm(getAlgorithm()); passwordEncoder.setAlgorithm(getAlgorithm());
} }
return passwordEncoder; return passwordEncoder;
@ -96,10 +115,14 @@ public class ARIA extends Cryptography {
return aria; return aria;
} }
public byte[] decrypt(byte[] encrypted) {
return service().decrypt(encrypted, key);
}
@Override @Override
protected String doDecrypt(String encrypted) { protected String doDecrypt(String encrypted) {
byte[] bytes = Base64.getDecoder().decode(encrypted); byte[] bytes = Base64.getDecoder().decode(encrypted);
return new String(service().decrypt(bytes, key)); return new String(decrypt(bytes));
} }
/** . /** .

@ -4,6 +4,7 @@
"class": "cokr.xit.base.crypto.bean.ARIA", "class": "cokr.xit.base.crypto.bean.ARIA",
"settings": { "settings": {
"key": "Copyright (c) 2015 - (주)엑스아이티", "key": "Copyright (c) 2015 - (주)엑스아이티",
// "hashedPassword": "", // 지정하지 않으면 key로 생성
"algorithm": "SHA-256", "algorithm": "SHA-256",
"blockSize": 1024 "blockSize": 1024
} }

Loading…
Cancel
Save