Exemple #1
0
 public void Decrypt(byte[] privateKey, byte[] otherKey)
 {
     if (privateKey != null && privateKey.Length > 0)
     {
         var wallet = new Wallet(privateKey);
         Decrypt(wallet, otherKey);
     }
     else
     {
         ExtendedMessage = new ExtendedMessage
         {
             Message   = "…could not decrypt…",
             Timestamp = Timestamp
         };
     }
 }
Exemple #2
0
 public void Decrypt(Wallet wallet, byte[] otherKey)
 {
     try
     {
         ExtendedMessage = JsonConvert.DeserializeObject <ExtendedMessage>(wallet.DecryptToString(Message, otherKey), new JsonSerializerSettings {
             DateTimeZoneHandling = DateTimeZoneHandling.Local
         });
     }
     catch (Exception ex)
     {
         try
         {
             ExtendedMessage = new ExtendedMessage
             {
                 Message   = wallet.DecryptToString(Message, otherKey),
                 Timestamp = Timestamp
             };
         }
         catch (Exception ex2)
         {
             try
             {
                 ExtendedMessage = JsonConvert.DeserializeObject <ExtendedMessage>(Encoding.UTF8.GetString(Message));
             }
             catch (Exception ex3)
             {
                 ExtendedMessage = new ExtendedMessage
                 {
                     Message   = "…could not decrypt…",
                     Timestamp = Timestamp
                 };
                 Debug.WriteLine(ex3);
             }
             Debug.WriteLine(ex2);
         }
         Debug.WriteLine(ex);
     }
 }