Exemple #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);
     }
 }
Exemple #2
0
        public string GetRealScopeIDFromEasyID(string pEasyID, bool bNoLogging = false, bool bUseEasyScope16 = false)
        {
            Guid   tG = CU.CGuid(MySecrets?.GetAK());
            string tg = InsertCodeIntoGUID(pEasyID, tG, bNoLogging, bUseEasyScope16).ToString();

            return(CU.cdeEncrypt(CU.CGuid(tg.Substring(0, 11) + tG.ToString().Substring(11, "00-0000-0000-000000000000".Length)).ToByteArray(), MySecrets?.GetAI()));
        }
 /// <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);
     }
 }