コード例 #1
0
ファイル: LogExtension.cs プロジェクト: wechat-cloud/lubala
 public static string Format(this IPassiveMessage message, HubContext context)
 {
     using (var stream = new MemoryStream())
     {
         message.SerializeTo(stream, context);
         stream.Position = 0;
         using (var reader = new StreamReader(stream))
         {
             return(reader.ReadToEnd());
         }
     }
 }
コード例 #2
0
        public IPassiveMessage EncryptMessage(IPassiveMessage message, CryptographyContext context)
        {
            using (var stream = new MemoryStream()) {
                message.SerializeTo(stream, context.HubContext);
                stream.Position = 0;
                using (var reader = new StreamReader(stream)) {
                    var originalMessage  = reader.ReadToEnd();
                    var encryptedMessage = EncryptMessage(originalMessage, context);
                    var signature        = GenarateSinature(originalMessage, context);

                    return(new EncryptedPassiveMessage {
                        MsgSignature = signature,
                        TimeStamp = context.MsgTimestamp,
                        Nonce = context.MsgNonce,
                        Encrypt = encryptedMessage
                    });
                }
            }
        }