JLChen
2021-11-15 501b06cda2eeda60456f317da3074b6c19cc9495
HDLSDK/hdl-connect/src/main/java/com/hdl/sdk/connect/protocol/LinkMessageDecoder.java
@@ -1,11 +1,10 @@
package com.hdl.sdk.connect.protocol;
import com.hdl.sdk.common.config.AuthenticateConfig;
import com.hdl.sdk.connect.config.HDLLinkConfig;
import com.hdl.sdk.common.event.EventDispatcher;
import com.hdl.sdk.common.utils.ByteUtils;
import com.hdl.sdk.connect.bean.LinkResponse;
import com.hdl.sdk.connect.utils.AESUtils;
import com.hdl.sdk.connect.utils.AesUtil;
import com.hdl.sdk.connect.utils.ProtocolParse;
import com.hdl.sdk.socket.codec.ByteToMessageDecoder;
@@ -60,9 +59,9 @@
                if (byteArray.length >= bodyLength + bodyStartIndex) {
                    byte[] body = ByteUtils.getRangeBytes(bytes, bodyStartIndex, bodyStartIndex + bodyLength);
                    if(AuthenticateConfig.getInstance().ifNeedEncrypt(response.getTopic())){
                    if(HDLLinkConfig.getInstance().ifNeedEncrypt(response.getTopic())){
                        //需要解密
                        byte[] bodyBytes = AesUtil.aesDecrypt(body,AuthenticateConfig.getInstance().getLocalSecret());
                        byte[] bodyBytes = AesUtil.aesDecrypt(body, HDLLinkConfig.getInstance().getLocalSecret());
//                        byte[] bodyBytes = AESUtils.decryptAES(body,AuthenticateConfig.getInstance().getLocalSecret());
                        response.setData(new String(bodyBytes, "utf-8"));
//                        Log.i("TAG", "解密 主题:"+response.getTopic()+ " body: "+response.getData());