XitArea 수정

master
mjkhan21 2 weeks ago
parent bb9eb4b64f
commit 92a9c1c2fc

@ -3,36 +3,50 @@ package cokr.xit.base.crypto.bean;
import cokr.xit.base.crypto.Cryptography;
public class XitAria extends Cryptography {
private int version;
private String key;
private int keySize;
private XitBridge bridge;
public XitAria(String name) {
super(name);
int version = def.settings().number("version").intValue();
setVersion(def.settings().number("version").intValue());
setKey(def.settings().string("key"));
setKeySize(def.settings().number("keySize").intValue());
// bridge = XitBridge.create(key, def.settings().string("charset"), keySize, version);
}
private XitBridge bridge() {
if (bridge == null)
bridge = XitBridge.create(key, def.settings().string("charset"), keySize, version);
return bridge;
}
public XitAria setVersion(int version) {
this.version = version;
bridge = null;
return this;
}
public XitAria setKey(String key) {
this.key = key;
bridge = null;
return this;
}
public XitAria setKeySize(int keySize) {
this.keySize = keySize< 1 ? 192 : keySize;
bridge = null;
return this;
}
@Override
protected String doEncrypt(String plain) throws Exception {
return bridge.encrypt(plain);
return bridge().encrypt(plain);
}
@Override
protected String doDecrypt(String encrypted) throws Exception {
return bridge.decrypt(encrypted);
return bridge().decrypt(encrypted);
}
}

@ -13,6 +13,7 @@
{ "name": "xit-aria",
"class": "cokr.xit.base.crypto.bean.XitAria",
"settings": {
// "version": 1,
"charset": "EUC-KR",
"key": "Copyright (c) 2015 - (주)엑스아이티",
"keySize": 192

@ -11,6 +11,7 @@ import org.junit.jupiter.api.Test;
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
@ -54,7 +55,7 @@ public class CryptographyTest /* extends TestSupport */ {
@Test
void xitAria() {
String name = "xit-aria";
Cryptography aria = Cryptography.get(name);
XitAria aria = (XitAria)Cryptography.get(name);
String plain = "7011102177320",
encrypted = aria.encrypt(plain),
@ -71,6 +72,19 @@ public class CryptographyTest /* extends TestSupport */ {
encrypted = "0EsqJtTQ+kaN3ISfI1g78IP9Rx9Vz9iiEliy1NV1G8w=";
decrypted = aria.decrypt(encrypted);
System.out.println(String.format("encrypted: %s -> decrypted: %s", encrypted, decrypted));
String key2 = new String(new byte[] {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F});
System.out.println(key2);
aria.setVersion(1)
.setKeySize(128)
// .setKey("3AsrGqpYYnkHIu3D")
.setKey(key2);
plain = "ZUDDN1129404";
encrypted = aria.encrypt(plain);
decrypted = aria.decrypt(encrypted);
System.out.println(String.format("plain: %s -> encrypted: %s -> decrypted: %s", plain, encrypted, decrypted));
System.out.println(aria.decrypt("OBSVd++xen8anRrG5jtFmg=="));
System.out.println(aria.decrypt("ryGrL2tVXRVHEQhYm7ps2g=="));
}
private String md5(String str) {

Loading…
Cancel
Save