Пример #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);
     }
 }
Пример #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);
     }
 }
Пример #3
0
        public string GetRealScopeID(string pScramScopeId)
        {
            if (string.IsNullOrEmpty(pScramScopeId))
            {
                return("");
            }

            pScramScopeId = pScramScopeId.Split(chunkSeparator, StringSplitOptions.None)[0];
            string[] tStr = CU.cdeDecrypt(pScramScopeId, MySecrets?.GetAI(), true).Split('&');
            MyServiceHostInfo?.MyKPIs?.IncrementKPI(eKPINames.KPI5);
            if (tStr.Length > 1 && MySecrets?.IsInApplicationScope(tStr[1]) == true)
            {
                return(tStr[1]);
            }
            else
            {
                return("");
            }
        }