Ejemplo n.º 1
0
 /// <summary>
 /// Decrypt incoming buffer array to a Dictionary.
 /// </summary>
 /// <param name="pInbuffer">incoming byte arrey to be decrypted</param>
 /// <returns></returns>
 public Dictionary <string, string> DecryptKV(byte[] pInbuffer)
 {
     try
     {
         var    fromEncrypt = Decrypt(pInbuffer, MySecrets?.GetAK(), MySecrets?.GetAI());
         string dec         = CU.CArray2UnicodeString(fromEncrypt, 0, fromEncrypt.Length);
         dec = dec.TrimEnd('\0');
         var pos = dec.IndexOf('@');
         if (pos < 0)
         {
             return(null);
         }
         var tPref = dec.Substring(0, pos);
         var tP    = tPref.Split(':');
         if (tP.Length < 2 || CU.CInt(tP[1]) != (dec.Substring(pos + 1)).Length)
         {
             return(null);
         }
         return(CU.DeserializeJSONStringToObject <Dictionary <string, string> >(dec.Substring(pos + 1)));
     }
     catch (Exception)
     {
         MySYSLOG?.WriteToLog(0, 5015, "ICDECrypto", $"Error during KV decrypt...", eMsgLevel.l1_Error);
         return(null);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Decrypt incoming buffer array to a Dictionary.
 /// </summary>
 /// <param name="pInbuffer">incoming byte arrey to be decrypted</param>
 /// <returns></returns>
 public Dictionary <string, string> DecryptKV(byte[] pInbuffer)
 {
     try
     {
         var    fromEncrypt = Decrypt(pInbuffer, MySecrets?.GetAK(), MySecrets?.GetAI());
         string dec         = CU.CArray2UnicodeString(fromEncrypt, 0, fromEncrypt.Length);
         dec = dec.TrimEnd('\0');
         return(CU.DeserializeJSONStringToObject <Dictionary <string, string> >(dec));
     }
     catch (Exception e)
     {
         TheBaseAssets.MySYSLOG?.WriteToLog(TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM("TheCommonUtils", $"Error during KV descrypt...", eMsgLevel.l1_Error)
         {
             PLS = e.ToString()
         }, 5015);
         return(null);
     }
 }