| | |
| | |
|
| | | import androidx.annotation.NonNull;
|
| | |
|
| | | import com.hdl.sdk.common.config.AuthenticateConfig;
|
| | | import com.hdl.sdk.connect.config.HDLLinkConfig;
|
| | | import com.hdl.sdk.common.utils.ByteUtils;
|
| | | import com.hdl.sdk.connect.utils.AESUtils;
|
| | | import com.hdl.sdk.connect.utils.AesUtil;
|
| | |
|
| | | import java.io.UnsupportedEncodingException;
|
| | | //import com.hdl.sdk.connect.utils.AesUtil;
|
| | |
|
| | | /**
|
| | | * Created by Tong on 2021/9/29.
|
| | |
| | | public byte[] getSendBytes() {
|
| | | try {
|
| | | //判断是否需要加密
|
| | | if (AuthenticateConfig.getInstance().ifNeedEncrypt(topic)) {
|
| | | if (HDLLinkConfig.getInstance().ifNeedEncrypt(topic)) {
|
| | | //需要加密
|
| | | byte[] dataBytes = AesUtil.aesEncrypt(ByteUtils.stringToBytes(data), AuthenticateConfig.getInstance().getLocalSecret());
|
| | | byte[] dataBytes = AesUtil.aesEncrypt(ByteUtils.stringToBytes(data), HDLLinkConfig.getInstance().getLocalSecret());
|
| | | // byte[] dataBytes = AESUtils.encryptAES(stringToBytes(data), AuthenticateConfig.getInstance().getLocalSecret());
|
| | |
|
| | | String headString = "Topic:" + getTopic() + "\r\n" + "Length:" + dataBytes.length + "\r\n" + "\r\n";
|