| | |
| | | package com.hdl.sdk.connect.protocol;
|
| | |
|
| | |
|
| | | import com.hdl.sdk.common.utils.LogUtils;
|
| | | import com.hdl.sdk.connect.config.HDLLinkConfig;
|
| | | import com.hdl.sdk.common.event.EventDispatcher;
|
| | | import com.hdl.sdk.common.utils.ByteUtils;
|
| | |
| | | if (byteArray.length >= bodyLength + bodyStartIndex) {
|
| | | byte[] body = ByteUtils.getRangeBytes(bytes, bodyStartIndex, bodyStartIndex + bodyLength);
|
| | |
|
| | | if(HDLLinkConfig.getInstance().ifNeedEncrypt(response.getTopic())){
|
| | | if (HDLLinkConfig.getInstance().ifNeedEncrypt(response.getTopic())) {
|
| | | //需要解密
|
| | | 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());
|
| | | }else{
|
| | | if (bodyBytes != null) {
|
| | | response.setData(new String(bodyBytes, "utf-8"));
|
| | | // LogUtils.i("TAG", "解密 主题:"+response.getTopic()+ " body: "+response.getData());
|
| | | } else {
|
| | | //解密失败,返回原数据
|
| | | response.setData(new String(body, "utf-8"));
|
| | | }
|
| | |
|
| | | } else {
|
| | | response.setData(new String(body, "utf-8"));
|
| | | }
|
| | |
|