| | |
| | | }
|
| | |
|
| | |
|
| | |
|
| | | private int getBytesLength(String str){
|
| | | private int getBytesLength(String str) {
|
| | | return ByteUtils.stringToBytes(str).length;
|
| | | }
|
| | |
|
| | |
| | | if (HDLLinkConfig.getInstance().ifNeedEncrypt(topic)) {
|
| | | //需要加密
|
| | | 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";
|
| | | byte[] headBytes = headString.getBytes("utf-8");
|
| | | byte[] sendBytes = ByteUtils.concatBytes(headBytes, dataBytes);
|
| | | return sendBytes;
|
| | |
|
| | | } else {
|
| | | return this.toString().getBytes("utf-8");
|
| | | }
|