整理依赖

This commit is contained in:
cheney 2022-04-02 17:31:58 +08:00
parent 3aa8237a4d
commit 2f103856c8
8 changed files with 471 additions and 471 deletions

27
pom.xml
View File

@ -4,7 +4,7 @@
<groupId>com.sunyard</groupId> <groupId>com.sunyard</groupId>
<artifactId>sydapi4j</artifactId> <artifactId>sydapi4j</artifactId>
<version>1.0.202201101633</version> <version>1.0.20220402</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>sydapi4j</name> <name>sydapi4j</name>
@ -19,6 +19,13 @@
<dependencies> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-pool2 --> <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-pool2 -->
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
@ -48,13 +55,6 @@
<version>1.6.1</version> <version>1.6.1</version>
</dependency> </dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.3.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson --> <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
@ -76,16 +76,11 @@
<dependency> <dependency>
<groupId>com.sunyard</groupId> <groupId>com.sunyard</groupId>
<artifactId>dproto</artifactId> <artifactId>proto</artifactId>
<version>1.0-20220107</version> <version>1.0-20220402</version>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!--<dependency>--> <!--<dependency>-->
<!--<groupId>club.fullstack</groupId>--> <!--<groupId>club.fullstack</groupId>-->

View File

@ -1,9 +1,55 @@
const l = require("./log") const l = require("./log")
const os = require("os");
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const util = require('util'); const util = require('util');
const cmd = require('node-cmd'); const { exec } = require('child_process')
const cmdget = util.promisify(cmd.get);
function sync( cmds , options = {}){
if ( options.detached ) {
throw "sync 不支持 detached"
}
options = Object.assign({
cwd : os.tmpdir(),
encoding: 'buffer'
}, options)
// 支持多命令
let cmd = cmds
// win 乱码问题
let encode = "win32" === os.platform() ? 'cp936' : "utf-8"
return new Promise(function (resolve, reject) {
let process = exec( cmd , options , function (e, stdout, stderr) {
// console.log( e,
// iconv.decode( stdout, 'cp936'),
// iconv.decode( stderr, 'cp936')
// )
if ( e ) {
reject( e )
} else {
resolve({
pid : process.pid,
exitCode : process.exitCode,
stdout : stdout,
stderr : stderr
})
}
})
console.log( "process", process.pid )
})
}
var version = "" var version = ""
const project_path = path.join(__dirname, "../") const project_path = path.join(__dirname, "../")
@ -19,7 +65,7 @@ function prepareDir(){
l.i("存在旧文件,清空旧文件") l.i("存在旧文件,清空旧文件")
} }
cmdget("rd /s/q .\\public").catch(function (reason) { sync("rd /s/q .\\public").catch(function (reason) {
// pass // pass
@ -45,7 +91,7 @@ function prepareDir(){
function mvn(){ function mvn(){
l.i("调用 maven 打包,可能需要好几分钟。") l.i("调用 maven 打包,可能需要好几分钟。")
return new Promise(function (cbok, cberr) { return new Promise(function (cbok, cberr) {
cmdget('mvn package -DskipTests').then(function (value, error) { sync('mvn package -DskipTests').then(function (value, error) {
l.d( value ) l.d( value )
if ( value.indexOf("BUILD SUCCESS") < 0 ){ if ( value.indexOf("BUILD SUCCESS") < 0 ){
@ -67,7 +113,7 @@ function mvn(){
} }
function doc(){ function doc(){
return cmdget('mvn javadoc:javadoc').then(function (value, error) { return sync('mvn javadoc:javadoc').then(function (value, error) {
l.d( value ) l.d( value )
// if ( value.indexOf("BUILD SUCCESS") < 0 ){ // if ( value.indexOf("BUILD SUCCESS") < 0 ){
@ -81,7 +127,7 @@ function doc(){
} }
function zipjar(){ function zipjar(){
return cmdget("7z a .\\public\\sydapi-"+ version +".zip .\\public\\jar\\").then(function (value, error) { return sync("7z a .\\public\\sydapi-"+ version +".zip .\\public\\jar\\").then(function (value, error) {
l.d( value ) l.d( value )
if ( value.indexOf("Everything is Ok") < 0 ){ if ( value.indexOf("Everything is Ok") < 0 ){
@ -92,7 +138,7 @@ function zipjar(){
} }
function zipdoc(){ function zipdoc(){
return cmdget("7z a .\\public\\sydapi-doc-"+ version +".zip .\\public\\doc\\ .\\public\\html\\ .\\src\\test\\java\\com\\sunyard\\sydapi\\sample .\\release.txt").then(function (value, error) { return sync("7z a .\\public\\sydapi-doc-"+ version +".zip .\\public\\doc\\ .\\public\\html\\ .\\src\\test\\java\\com\\sunyard\\sydapi\\sample .\\release.txt").then(function (value, error) {
l.d( value ) l.d( value )
if ( value.indexOf("Everything is Ok") < 0 ){ if ( value.indexOf("Everything is Ok") < 0 ){
@ -104,7 +150,7 @@ function zipdoc(){
function dependencies(){ function dependencies(){
return cmdget('mvn dependency:copy-dependencies -DoutputDirectory=./public/jar/dependences').then(function (value, error) { return sync('mvn dependency:copy-dependencies -DoutputDirectory=./public/jar/dependences').then(function (value, error) {
l.d( value ) l.d( value )
if ( value.indexOf("BUILD SUCCESS") < 0 ){ if ( value.indexOf("BUILD SUCCESS") < 0 ){
@ -119,7 +165,7 @@ async function main() {
l.i("项目目录 : " + project_path ) l.i("项目目录 : " + project_path )
cmdget('git status').then(function (value, error) { sync('git status').then(function (value, error) {
l.d( value ) l.d( value )
@ -141,7 +187,7 @@ async function main() {
l.i( r.groups.version ) l.i( r.groups.version )
version = r.groups.version version = r.groups.version
return cmdget('git log -1') return sync('git log -1')
}).then(function (value) { }).then(function (value) {
@ -193,7 +239,7 @@ async function main() {
}).then(function () { }).then(function () {
l.i("打包完成!") l.i("打包完成!")
cmdget('start .\\public') sync('start .\\public')
}).catch(function (reason) { }).catch(function (reason) {

View File

@ -1,2 +1,3 @@
/proto/ /proto/
/script/ /script/
/dto/

View File

@ -1,381 +1,381 @@
package racal.sunyard.main; //package racal.sunyard.main;
//
import com.sunyard.SydApiException; //import com.sunyard.SydApiException;
import com.sunyard.SydApiSDF; //import com.sunyard.SydApiSDF;
import com.sunyard.entity.DeviceInfo; //import com.sunyard.entity.DeviceInfo;
import com.sunyard.proto.Packet; //import com.sunyard.proto.Packet;
import com.sunyard.proto.PacketSection; //import com.sunyard.proto.PacketSection;
import com.sunyard.proto.Util; //import com.sunyard.proto.Util;
import com.sunyard.trans.PacketSN; //import com.sunyard.trans.PacketSN;
import racal.sunyard.main.proto.Proto0100; //import racal.sunyard.main.proto.Proto0100;
import racal.sunyard.main.proto.Proto0101; //import racal.sunyard.main.proto.Proto0101;
import racal.sunyard.main.proto.ProtoSK; //import racal.sunyard.main.proto.ProtoSK;
//
import java.io.IOException; //import java.io.IOException;
import java.io.InputStream; //import java.io.InputStream;
import java.net.InetSocketAddress; //import java.net.InetSocketAddress;
import java.net.Socket; //import java.net.Socket;
import java.net.SocketAddress; //import java.net.SocketAddress;
import java.net.SocketTimeoutException; //import java.net.SocketTimeoutException;
import java.nio.ByteBuffer; //import java.nio.ByteBuffer;
import java.util.Arrays; //import java.util.Arrays;
import java.util.HashMap; //import java.util.HashMap;
import java.util.Map; //import java.util.Map;
//
public class SydApiSDF4j implements SydApiSDF { //public class SydApiSDF4j implements SydApiSDF {
//
private static boolean debug = false; // private static boolean debug = false;
//
private static long sTime = System.currentTimeMillis(); // private static long sTime = System.currentTimeMillis();
//
private static String ip1; // private static String ip1;
private static String ip2; // private static String ip2;
private static int port; // private static int port;
private static int timeout; // private static int timeout;
//
private Socket socket; // private Socket socket;
//
//初始化变量 // //初始化变量
static { // static {
//
String d = System.getProperty("com.sunyard.sydapi4j.debug"); // String d = System.getProperty("com.sunyard.sydapi4j.debug");
if ("true".equals(d)) { // if ("true".equals(d)) {
debug = true; // debug = true;
} // }
} // }
//
private static void println(Object i) { // private static void println(Object i) {
if (debug) { // if (debug) {
System.out.println(i); // System.out.println(i);
} // }
//
} // }
//
private static void print(Object i) { // private static void print(Object i) {
if (debug) { // if (debug) {
System.out.print(i); // System.out.print(i);
} // }
//
} // }
//
//gc回收 // //gc回收
@Override // @Override
protected void finalize() throws Throwable { // protected void finalize() throws Throwable {
super.finalize(); // super.finalize();
if (null != this.socket) { // if (null != this.socket) {
this.socket.close(); // this.socket.close();
} // }
} // }
//
/** // /**
* 确认链接可用 // * 确认链接可用
* 确认读缓存为空 // * 确认读缓存为空
*/ // */
private void testSocket() { // private void testSocket() {
//
// 就是简单对象模式链接长短完全由用户自己控制 // // 就是简单对象模式链接长短完全由用户自己控制
if (null == socket) { // if (null == socket) {
//
// 全局热备模式old shool // // 全局热备模式old shool
if (null != ip2) { // if (null != ip2) {
//
Socket s1 = new Socket(); // Socket s1 = new Socket();
SocketAddress address = new InetSocketAddress(ip1, port); // SocketAddress address = new InetSocketAddress(ip1, port);
//
try { // try {
s1.connect(address, timeout); // s1.connect(address, timeout);
socket = s1; // socket = s1;
socket.setSoTimeout(timeout); // socket.setSoTimeout(timeout);
} catch (Exception e) { // } catch (Exception e) {
Socket s2 = new Socket(); // Socket s2 = new Socket();
SocketAddress add2 = new InetSocketAddress(ip2, port); // SocketAddress add2 = new InetSocketAddress(ip2, port);
try { // try {
s2.connect(add2, timeout); // s2.connect(add2, timeout);
socket = s2; // socket = s2;
socket.setSoTimeout(timeout); // socket.setSoTimeout(timeout);
} catch (Exception e2) { // } catch (Exception e2) {
throw new SydApiException(-2); // throw new SydApiException(-2);
} // }
} // }
//
} // }
} // }
//
clear(); // clear();
//
} // }
//
protected byte[] syncSend(ByteBuffer bb) { // protected byte[] syncSend(ByteBuffer bb) {
//
//
byte[] buff; // byte[] buff;
if (bb.position() == bb.limit()) { // if (bb.position() == bb.limit()) {
buff = bb.array(); // buff = bb.array();
} else { // } else {
buff = new byte[bb.position()]; // buff = new byte[bb.position()];
System.arraycopy(bb.array(), 0, buff, 0, buff.length); // System.arraycopy(bb.array(), 0, buff, 0, buff.length);
} // }
//
//
println("\n\n发送数据"); // println("\n\n发送数据");
print("HEX数据: \t"); // print("HEX数据: \t");
println(Util.bytes2HexString(buff)); // println(Util.bytes2HexString(buff));
//
testSocket(); // testSocket();
//
try { // try {
socket.getOutputStream().write(buff); // socket.getOutputStream().write(buff);
} catch (IOException e) { // } catch (IOException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
//
return buff; // return buff;
} // }
//
private void clear() { // private void clear() {
try { // try {
InputStream is = socket.getInputStream(); // InputStream is = socket.getInputStream();
while (is.available() > 0) { // while (is.available() > 0) {
is.read(); // is.read();
} // }
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
} // }
//
//
private ByteBuffer read(Socket socket) throws IOException { // private ByteBuffer read(Socket socket) throws IOException {
InputStream is = socket.getInputStream(); // InputStream is = socket.getInputStream();
int d; // int d;
int high = is.read(); // int high = is.read();
int low = is.read(); // int low = is.read();
int len = (high << 8) + low; // int len = (high << 8) + low;
//
len += 2; // len += 2;
//
print("H\t"); // print("H\t");
println(Integer.toHexString(high)); // println(Integer.toHexString(high));
print("L\t"); // print("L\t");
println(Integer.toHexString(low)); // println(Integer.toHexString(low));
print("Len\t"); // print("Len\t");
println(len); // println(len);
//
//
ByteBuffer bb = ByteBuffer.allocate(len); // ByteBuffer bb = ByteBuffer.allocate(len);
bb.put((byte) (high & 0xFF)); // bb.put((byte) (high & 0xFF));
bb.put((byte) (low & 0xFF)); // bb.put((byte) (low & 0xFF));
//
while (true) { // while (true) {
d = is.read(); // d = is.read();
if (-1 == d) { // if (-1 == d) {
break; // break;
} // }
//
bb.put((byte) (d & 0xFF)); // bb.put((byte) (d & 0xFF));
//
if (bb.position() == len) { // if (bb.position() == len) {
break; // break;
} // }
} // }
//
print("HEX数据: \t"); // print("HEX数据: \t");
println(Util.bytes2HexString(bb.array())); // println(Util.bytes2HexString(bb.array()));
return bb; // return bb;
} // }
//
/** // /**
* 阻塞读取 // * 阻塞读取
* 前两个字节是长度 // * 前两个字节是长度
* // *
* @return // * @return
* @buffer 如果出错需要补发的数据 // * @buffer 如果出错需要补发的数据
*/ // */
protected ByteBuffer syncRead(byte[] buffer) { // protected ByteBuffer syncRead(byte[] buffer) {
println("\n\n接收数据"); // println("\n\n接收数据");
try { // try {
// 正常接收 // // 正常接收
ByteBuffer bb = read(socket); // ByteBuffer bb = read(socket);
return bb; // return bb;
//
} catch (SocketTimeoutException e) { // } catch (SocketTimeoutException e) {
throw new SydApiException("接收数据超时", -2); // throw new SydApiException("接收数据超时", -2);
} catch (Exception e) { // } catch (Exception e) {
e.printStackTrace(); // e.printStackTrace();
} // }
//
throw new SydApiException("通信数据错误", -3); // throw new SydApiException("通信数据错误", -3);
} // }
//
@Override // @Override
synchronized public SydApiSDF connect(String ip, int port, String pwd, int timeout) { // synchronized public SydApiSDF connect(String ip, int port, String pwd, int timeout) {
//
if (null != ip2) { // if (null != ip2) {
throw new SydApiException("双机热备模式不用调用此方法", -1); // throw new SydApiException("双机热备模式不用调用此方法", -1);
} // }
Socket socket = new Socket(); // Socket socket = new Socket();
SocketAddress address = new InetSocketAddress(ip, port); // SocketAddress address = new InetSocketAddress(ip, port);
//
try { // try {
if (timeout > 0) { // if (timeout > 0) {
socket.connect(address, timeout); // socket.connect(address, timeout);
} else { // } else {
socket.connect(address); // socket.connect(address);
} // }
socket.setSoTimeout(timeout); // socket.setSoTimeout(timeout);
} catch (Exception e) { // } catch (Exception e) {
throw new SydApiException(-2); // throw new SydApiException(-2);
} // }
//
this.socket = socket; // this.socket = socket;
return this; // return this;
} // }
//
@Override // @Override
synchronized public SydApiSDF connect(String ip, int port, String pwd, int connectTimeout, int readTimeout) { // synchronized public SydApiSDF connect(String ip, int port, String pwd, int connectTimeout, int readTimeout) {
//
if (null != ip2) { // if (null != ip2) {
throw new SydApiException("双机热备模式不用调用此方法", -1); // throw new SydApiException("双机热备模式不用调用此方法", -1);
} // }
Socket socket = new Socket(); // Socket socket = new Socket();
SocketAddress address = new InetSocketAddress(ip, port); // SocketAddress address = new InetSocketAddress(ip, port);
//
try { // try {
socket.connect(address, connectTimeout); // socket.connect(address, connectTimeout);
socket.setSoTimeout(readTimeout); // socket.setSoTimeout(readTimeout);
} catch (Exception e) { // } catch (Exception e) {
throw new SydApiException(-2); // throw new SydApiException(-2);
} // }
//
this.socket = socket; // this.socket = socket;
return this; // return this;
} // }
//
@Override // @Override
synchronized public int disconnect() { // synchronized public int disconnect() {
//
if (null != socket) { // if (null != socket) {
try { // try {
socket.getInputStream().close(); // socket.getInputStream().close();
} catch (Exception e1) { // } catch (Exception e1) {
} // }
//
//
try { // try {
socket.getOutputStream().close(); // socket.getOutputStream().close();
} catch (Exception e2) { // } catch (Exception e2) {
} // }
//
try { // try {
socket.close(); // socket.close();
} catch (Exception e) { // } catch (Exception e) {
} // }
//
} // }
//
return 0; // return 0;
} // }
//
@Override // @Override
public DeviceInfo getStatus() { // public DeviceInfo getStatus() {
//
Proto0100 proto = new Proto0100(); // Proto0100 proto = new Proto0100();
//
HashMap<String, Object> packet = new HashMap<String, Object>(); // HashMap<String, Object> packet = new HashMap<String, Object>();
HashMap<String, Object> data = new HashMap<String, Object>(); // HashMap<String, Object> data = new HashMap<String, Object>();
PacketSN sn = PacketSN.gen(); // PacketSN sn = PacketSN.gen();
packet.put("header", sn.getSn().array()); // packet.put("header", sn.getSn().array());
packet.put("data", data); // packet.put("data", data);
//
// 渲染发送 // // 渲染发送
ByteBuffer bb = proto.rend(packet); // ByteBuffer bb = proto.rend(packet);
//
synchronized (this) { // synchronized (this) {
// 响应解析 // // 响应解析
bb = syncRead(syncSend(bb)); // bb = syncRead(syncSend(bb));
} // }
//
Packet p = proto.parse(bb); // Packet p = proto.parse(bb);
Map<String, Object> ret = p.toMap(); // Map<String, Object> ret = p.toMap();
//
if ( // if (
!Arrays.equals(sn.getSn().array(), ((PacketSection) ret.get("header")).getBytes()) // !Arrays.equals(sn.getSn().array(), ((PacketSection) ret.get("header")).getBytes())
) { // ) {
throw new SydApiException("包序号不匹配", -4); // throw new SydApiException("包序号不匹配", -4);
} // }
//
ret = (Map<String, Object>) ret.get("data"); // ret = (Map<String, Object>) ret.get("data");
PacketSection error = (PacketSection) ret.get("error"); // PacketSection error = (PacketSection) ret.get("error");
byte[] be = error.getBytes(); // byte[] be = error.getBytes();
if ((0 != (be[0] ^ be[1]))) { // if ((0 != (be[0] ^ be[1]))) {
throw new SydApiException(error.getInfo(), error.autoInt()); // throw new SydApiException(error.getInfo(), error.autoInt());
} // }
//
byte[] deviceinfo = ((PacketSection) ret.get("deviceinfo")).getBytes(); // byte[] deviceinfo = ((PacketSection) ret.get("deviceinfo")).getBytes();
//
return new DeviceInfo(deviceinfo); // return new DeviceInfo(deviceinfo);
} // }
//
@Override // @Override
public byte[] directBytes(byte[] data) { // public byte[] directBytes(byte[] data) {
//初始化一个和byte长度一样的bb // //初始化一个和byte长度一样的bb
ByteBuffer bb = ByteBuffer.allocate(data.length); // ByteBuffer bb = ByteBuffer.allocate(data.length);
// 数组放到bb中 // // 数组放到bb中
bb.put(data); // bb.put(data);
//
//发送数据,解析 // //发送数据,解析
synchronized (this) { // synchronized (this) {
bb = syncRead(syncSend(bb)); // bb = syncRead(syncSend(bb));
} // }
//重置 limit 和postion // //重置 limit 和postion
bb.flip(); // bb.flip();
//获取bb中有效大小 // //获取bb中有效大小
int len = bb.limit() - bb.position(); // int len = bb.limit() - bb.position();
//
byte[] bytes = new byte[len]; // byte[] bytes = new byte[len];
for (int i = 0; i < bytes.length; i++) { // for (int i = 0; i < bytes.length; i++) {
bytes[i] = bb.get(); // bytes[i] = bb.get();
} // }
return bytes; // return bytes;
} // }
//
/** // /**
* 获取随机数 // * 获取随机数
* @param randLen 随机数长度 // * @param randLen 随机数长度
* @return // * @return
*/ // */
public byte[] genRandom(int randLen) { // public byte[] genRandom(int randLen) {
//获取协议 // //获取协议
Proto0101 proto = new Proto0101(); // Proto0101 proto = new Proto0101();
//
//填充数据 // //填充数据
PacketSN sn = PacketSN.gen(); // PacketSN sn = PacketSN.gen();
HashMap<String, Object> packet = new HashMap<String, Object>(); // HashMap<String, Object> packet = new HashMap<String, Object>();
packet.put("header", sn.getSn().array()); // packet.put("header", sn.getSn().array());
HashMap<String, Object> data = new HashMap<String, Object>(); // HashMap<String, Object> data = new HashMap<String, Object>();
data.put("randLen", randLen); // data.put("randLen", randLen);
packet.put("data", data); // packet.put("data", data);
//
//渲染发送 // //渲染发送
ByteBuffer bb = proto.rend(packet); // ByteBuffer bb = proto.rend(packet);
//
synchronized (this) { // synchronized (this) {
//解析响应 // //解析响应
bb = syncRead(syncSend(bb)); // bb = syncRead(syncSend(bb));
} // }
Packet p = proto.parse(bb, packet); // Packet p = proto.parse(bb, packet);
Map<String, Object> ret = p.toMap(); // Map<String, Object> ret = p.toMap();
if ( // if (
!Arrays.equals(sn.getSn().array(), ((PacketSection) ret.get("header")).getBytes()) // !Arrays.equals(sn.getSn().array(), ((PacketSection) ret.get("header")).getBytes())
) { // ) {
throw new SydApiException("包序号不匹配", -4); // throw new SydApiException("包序号不匹配", -4);
} // }
ret = (Map<String, Object>) ret.get("data"); // ret = (Map<String, Object>) ret.get("data");
PacketSection error = (PacketSection) ret.get("error"); // PacketSection error = (PacketSection) ret.get("error");
byte[] be = error.getBytes(); // byte[] be = error.getBytes();
if ((0 != (be[0] ^ be[1]))) { // if ((0 != (be[0] ^ be[1]))) {
throw new SydApiException(error.getInfo(), error.autoInt()); // throw new SydApiException(error.getInfo(), error.autoInt());
} // }
//
return ((PacketSection) ret.get("randData")).getBytes(); // return ((PacketSection) ret.get("randData")).getBytes();
} // }
} //}

View File

@ -1,40 +0,0 @@
package racal.sunyard.main;
import com.sunyard.SydApi;
import java.util.Scanner;
import java.io.UnsupportedEncodingException;
public class TestDecryptDataWithFile
{
public static void main(String[] args) throws Exception {
System.out.println("SydApi 测试程序启动");
SydApi key = new SydApi4j().connect("192.168.0.71",8889,null,10000);
System.out.println("连接成功");
String seesionKey = "X246F7CEC2EF09A7A8F0475C6B1CE4B05";
String inputPath = "c:\\Users\\KJ-Z285\\Desktop\\dataEncrypt.txt";
String outputPath = "c:\\Users\\KJ-Z285\\Desktop\\dataDncrypt.txt";
System.out.println("[Tips]:" + "正在解密,请稍候...\n" );
if (!key.SYMDecryptDataWithFile(0x01, seesionKey, inputPath, outputPath))
{
System.out.println("[Error]:" + "解密失败!\n" );
}
System.out.println("[Tips]:" + "解密完成!\n" );
System.out.println("执行结束\n\n" );
key.disconnect();
//
// Scanner scanner = new Scanner(System.in);
// String in = scanner.nextLine();
}
}

View File

@ -1,9 +1,13 @@
package racal.sunyard.main; package com.sunyard.sydapi.test;
import com.sunyard.util.SYMUtil;
public class TestClass implements TestInf{ public class TestClass implements TestInf{
@Override @Override
public void run() { public void run() {
System.out.println( "class=" + TestClass.class.getName() ); System.out.println( "class=" + TestClass.class.getName() );
System.out.println( "classloader" + TestClass.class.getClassLoader().getClass().getName() ); System.out.println( "classloader" + TestClass.class.getClassLoader().getClass().getName() );
} }

View File

@ -1,11 +1,10 @@
package com.sunyard.sydapi.test; package com.sunyard.sydapi.test;
import com.sunyard.SydApi; import com.sunyard.SydApi;
import com.sunyard.proto.Util;
import racal.sunyard.main.SydApi4j;
import java.io.*; import java.util.Scanner;
import java.io.UnsupportedEncodingException;
public class TestDecryptDataWithFile public class TestDecryptDataWithFile
@ -14,33 +13,28 @@ public class TestDecryptDataWithFile
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
System.out.println("SydApi 测试程序启动"); System.out.println("SydApi 测试程序启动");
SydApi key = new SydApi4j().connect("172.16.18.74",8889,null,10000); SydApi key = new SydApi4j().connect("192.168.0.71",8889,null,10000);
System.out.println("连接成功"); System.out.println("连接成功");
long startTime = System.currentTimeMillis(); //获取开始时间 String seesionKey = "X246F7CEC2EF09A7A8F0475C6B1CE4B05";
String inputPath = "c:\\Users\\KJ-Z285\\Desktop\\dataEncrypt.txt";
String outputPath = "c:\\Users\\KJ-Z285\\Desktop\\dataDncrypt.txt";
byte[] bytes = Util.hexString2Bytes("CBB5DF1ECDB7564EFDA62076632F459BD8F618DC060A5AC368848C5A1D78A85CAFA26F8228F446E2ABA5AEA8F32CF91B606CFD2125766DD3A4E47F4DD22D3A198C2000E9C6F1B73FA33BFE13A00D3612DC9D7C2811A7C1ABAEDBAEEBE8E18D9A2CD670A2526E98C50C4F9205FDE32162E7C8583154D5DDEF2D1B71C6C1636F684BCF865A8EC852C389DEB381728806AC5659E7980651528C0B6F86A47881A66F2C21317D778253786765D60EAA73BC7C6C4CE658BB5231A4FE7282646B0DC774E0B56E38DA29FBA654DB6973661BC65227751E98AB2DD1EBB8076E32D1DB8712"); System.out.println("[Tips]:" + "正在解密,请稍候...\n" );
if (!key.SYMDecryptDataWithFile(0x01, seesionKey, inputPath, outputPath))
String inputPath = "c:\\Users\\MrYang\\Desktop\\dataEncrypt.txt"; {
String outputPath = "c:\\Users\\MrYang\\Desktop\\dataDncrypt.txt"; System.out.println("[Error]:" + "解密失败!\n" );
try {
FileOutputStream fileWriter =new FileOutputStream(inputPath);
fileWriter.write(bytes);
fileWriter.flush();
fileWriter.close();
}catch (IOException e){
e.printStackTrace();
} }
System.out.println("[Tips]:" + "解密完成!\n" );
key.SYMDecryptDataWithFile(1, "X246F7CEC2EF09A7A8F0475C6B1CE4B05", inputPath, outputPath);
long endTime=System.currentTimeMillis(); //获取结束时间
System.out.println("程序运行时间: "+(endTime-startTime)+"ms");
System.out.println("执行结束\n\n" ); System.out.println("执行结束\n\n" );
key.disconnect(); key.disconnect();
//
// Scanner scanner = new Scanner(System.in);
// String in = scanner.nextLine();
} }
} }

View File

@ -1,4 +1,4 @@
package racal.sunyard.main; package com.sunyard.sydapi.test;
public interface TestInf { public interface TestInf {
public void run(); public void run();