From 2f12fbcba76c3fbd599eaa0a069a49716426acc9 Mon Sep 17 00:00:00 2001 From: mjkhan21 Date: Thu, 18 Jul 2024 17:47:05 +0900 Subject: [PATCH] =?UTF-8?q?Cryptography.get(String)=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/cokr/xit/base/crypto/Cryptography.java | 9 +++++++++ src/test/java/cokr/xit/base/crypto/CryptographyTest.java | 6 ++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/cokr/xit/base/crypto/Cryptography.java b/src/main/java/cokr/xit/base/crypto/Cryptography.java index c223ce8..7569017 100644 --- a/src/main/java/cokr/xit/base/crypto/Cryptography.java +++ b/src/main/java/cokr/xit/base/crypto/Cryptography.java @@ -19,6 +19,15 @@ import cokr.xit.foundation.data.JSON; * @author mjkhan */ public abstract class Cryptography extends AbstractComponent { + /**설정파일(xit-crypto.conf)에서 지정한 이름의 설정을 읽어 Cryptography를 반환한다. + * @param name 설정 이름 + * @return Cryptography + */ + public static Cryptography get(String name) { + CryptoDef def = Config.conf.getCryptoDef(name); + return def.newCrypto(); + } + /** 암복호화 설정정보 */ protected CryptoDef def; protected String charset; diff --git a/src/test/java/cokr/xit/base/crypto/CryptographyTest.java b/src/test/java/cokr/xit/base/crypto/CryptographyTest.java index 4487d53..68ee18b 100644 --- a/src/test/java/cokr/xit/base/crypto/CryptographyTest.java +++ b/src/test/java/cokr/xit/base/crypto/CryptographyTest.java @@ -7,10 +7,8 @@ import org.apache.commons.beanutils.PropertyUtils; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; -import cokr.xit.base.crypto.bean.ARIA; import cokr.xit.base.crypto.bean.DGuard; import cokr.xit.base.crypto.bean.Echelon; -import cokr.xit.base.crypto.bean.XitAria; public class CryptographyTest /* extends TestSupport */ { private String @@ -37,7 +35,7 @@ public class CryptographyTest /* extends TestSupport */ { @Test void aria() { String name = "aria"; - Cryptography aria = new ARIA(name); + Cryptography aria = Cryptography.get(name); Assertions.assertEquals(name, aria.name()); String encrypted = aria.encrypt(text), @@ -54,7 +52,7 @@ public class CryptographyTest /* extends TestSupport */ { @Test void xitAria() { String name = "xit-aria"; - Cryptography aria = new XitAria(name); + Cryptography aria = Cryptography.get(name); String str = "7011102177320", encrypted = aria.encrypt(str),