/// <summary>
        /// Return a Scrambled ScopeID from an easy scopeID
        /// </summary>
        /// <param name="pEasyScope">Source EasyScope</param>
        /// <param name="bNoLogging">If true, errors will not be logged</param>
        /// <param name="bUseEasyScope16">if true, the EasyScopeID can have up to 16 characters. Attention: this might not be compatible to existing mesh setups as all nodes in a mesh need to understand 16chars ScopeIDs</param>
        /// <returns></returns>
        public string GetScrambledScopeIDFromEasyID(string pEasyScope, bool bNoLogging, bool bUseEasyScope16)
        {
            if (string.IsNullOrEmpty(pEasyScope))
            {
                return(null);                                   //NEW 10/20/2012
            }
            Guid tG = CU.CGuid(TheBaseAssets.MySecrets.GetAK());

            MyServiceHostInfo?.MyKPIs?.IncrementKPI(eKPINames.KPI4);
            return(Base64Encode($"{CU.GetRandomUInt(0, 1000)}&{InsertCodeIntoGUID(pEasyScope, tG, bUseEasyScope16)}"));
        }
示例#2
0
        /// <summary>
        /// Return a Scrambled ScopeID from an easy scopeID
        /// </summary>
        /// <param name="pEasyScope">Source EasyScope</param>
        /// <param name="bNoLogging">If true, errors will not be logged</param>
        /// <param name="bUseEasyScope16">if true, the EasyScopeID can have up to 16 characters. Attention: this might not be compatible to existing mesh setups as all nodes in a mesh need to understand 16chars ScopeIDs</param>
        /// <returns></returns>
        public string GetScrambledScopeIDFromEasyID(string pEasyScope, bool bNoLogging, bool bUseEasyScope16)
        {
            if (string.IsNullOrEmpty(pEasyScope))
            {
                return(null);                                   //NEW 10/20/2012
            }
            Guid   tG = CU.CGuid(MySecrets?.GetAK());
            string tg = InsertCodeIntoGUID(pEasyScope, tG, bNoLogging, bUseEasyScope16).ToString();

            MyServiceHostInfo?.MyKPIs?.IncrementKPI(eKPINames.KPI4);
            return(CU.cdeEncrypt(CU.GetRandomUInt(0, 1000) + "&" + CU.cdeEncrypt(CU.CGuid(tg.Substring(0, 11) + tG.ToString().Substring(11, "00-0000-0000-000000000000".Length)).ToByteArray(), MySecrets?.GetAI()), MySecrets?.GetAI()));
        }
示例#3
0
 /// <summary>
 /// Encryptes a dictionary to a byte array
 /// </summary>
 /// <param name="pVal">Dictionary to be encrypted</param>
 /// <returns></returns>
 public byte[] EncryptKV(Dictionary <string, string> pVal)
 {
     try
     {
         string t      = CU.SerializeObjectToJSONString(pVal);
         var    tFinal = $"{CU.GetRandomUInt(0, 10000)}:{t.Length}@" + t;
         return(Encrypt(CU.CUnicodeString2Array(tFinal), MySecrets?.GetAK(), MySecrets?.GetAI()));
     }
     catch (Exception)
     {
         MySYSLOG?.WriteToLog(0, 5016, "ICDECrypto", $"Error during KV encrypt...", eMsgLevel.l1_Error);
         return(null);
     }
 }
示例#4
0
        public string GetScrambledScopeID(string pRealScopeID, bool IsRealId)
        {
            if (string.IsNullOrEmpty(pRealScopeID))
            {
                return("");
            }

            MyServiceHostInfo?.MyKPIs?.IncrementKPI(eKPINames.KPI4);
            if (IsRealId)
            {
                return(CU.cdeEncrypt(CU.GetRandomUInt(0, 1000) + "&" + pRealScopeID, MySecrets?.GetAI()));
            }
            else
            {
                return(CU.cdeEncrypt(CU.GetRandomUInt(0, 1000) + "&" + GetRealScopeID(pRealScopeID), MySecrets?.GetAI())); //GRSI: Low frequency
            }
        }
        public string GetScrambledScopeID(string pRealScopeID, bool IsRealId)
        {
            if (string.IsNullOrEmpty(pRealScopeID))
            {
                return("");
            }

            MyServiceHostInfo?.MyKPIs?.IncrementKPI(eKPINames.KPI4);
            if (IsRealId)
            {
                return(Base64Encode(CU.GetRandomUInt(0, 1000) + "&" + pRealScopeID));
            }
            else
            {
                return(Base64Encode(CU.GetRandomUInt(0, 1000) + "&" + GetRealScopeID(pRealScopeID)));
            }
        }
示例#6
0
        public string GetScrambledScopeID()
        {
            if (!IsScopingEnabled)
            {
                return("");
            }
            if (FastSScopeID != null)
            {
                return(FastSScopeID);
            }
            MyServiceHostInfo?.MyKPIs?.IncrementKPI(eKPINames.KPI4);
            string t = CU.cdeEncrypt(CU.GetRandomUInt(0, 1000) + "&" + ScopeID, MySecrets?.GetAI());

            if (MyServiceHostInfo?.EnableFastSecurity == true)
            {
                FastSScopeID = t;
            }
            return(t);
        }
        public string GetISBPath(string PathPrefix, cdeSenderType pOriginType, cdeSenderType pDestinationType, long pCounter, Guid pSessionID, bool IsWS)
        {
            if (string.IsNullOrEmpty(TheBaseAssets.MySecrets.GetApID5()))
            {
                return("");
            }
            if (string.IsNullOrEmpty(PathPrefix))
            {
                PathPrefix = "/";
            }
            else
            {
                if (!PathPrefix.EndsWith("/"))
                {
                    PathPrefix += "/";
                }
            }
            string pSessID = pSessionID.ToString();

            if (pCounter == 1 && pSessionID == Guid.Empty && !(MyServiceHostInfo?.UseFixedConnectionUrl == true))
            {
                pSessID = "P" + GetCryptoGuid().ToString().Substring(1);
            }
            MyServiceHostInfo?.MyKPIs?.IncrementKPI(eKPINames.KPI4);
            string tPath = PathPrefix + "ISB" + Uri.EscapeUriString(Base64Encode($"{string.Format("{0:00000}",CU.GetRandomUInt(0, 99999))}{(string.IsNullOrEmpty(MyServiceHostInfo?.ProtocolVersion)?"40":MyServiceHostInfo?.ProtocolVersion)}_{pCounter}_{((int)(pOriginType))}_{pSessID}"));

            if (IsWS && (pDestinationType == cdeSenderType.CDE_CLOUDROUTE || pDestinationType == cdeSenderType.CDE_SERVICE || pDestinationType == cdeSenderType.CDE_CUSTOMISB))
            {
                tPath += ".ashx";
            }
            return(tPath);
        }