| | |
| | | /// </summary> |
| | | static void SendPushSignOut () |
| | | { |
| | | #if DEBUG |
| | | return; |
| | | #endif |
| | | |
| | | byte [] message = CommonPage.MyEncodingUTF8.GetBytes (PushSignStr); |
| | | MqttRemoteSend (message, 4); |
| | | } |
| | |
| | | case 0: |
| | | topicName = $"/ClientToBusGateWay/{CommonConfig.Current.HomeGatewayInfo.gatewayId}/Common/ON"; |
| | | if (!string.IsNullOrEmpty (mqttEncryptKey)) { |
| | | //Utlis.WriteLine ("mqttEncryptKey:" + mqttEncryptKey); |
| | | message = Shared.Securitys.EncryptionService.AesEncryptPayload (message, mqttEncryptKey); |
| | | } |
| | | await RemoteMqttClient.PublishAsync (new MqttApplicationMessage { Topic = topicName, Payload = message, Retain = false, QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce }); |
| | |
| | | public partial class EncryptionService |
| | | { |
| | | |
| | | #region 加密 |
| | | #region 加密 |
| | | /// <summary> |
| | | /// 加密主题为Base64 |
| | | /// </summary> |
| | |
| | | //使用AES将明文流转成密文字节数组 |
| | | return cTransform.TransformFinalBlock (toEncryptArray, 0, toEncryptArray.Length); |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | |
| | | #region 解密 |
| | | #region 解密 |
| | | /// <summary> |
| | | /// 解密主题数据 |
| | | /// </summary> |
| | |
| | | //使用AES将密文流转成明文的字节数组 |
| | | return cTransform.TransformFinalBlock (toEncryptArray, 0, toEncryptArray.Length); |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | |
| | | |