Пример #1
0
        private static double ComputePathCost(List <QePatternInstance> l,
                                              char[] vPassword, EntropyEncoder ecPattern, MultiEntropyEncoder mcData)
        {
            ecPattern.Reset();
            for (int i = 0; i < l.Count; ++i)
            {
                ecPattern.Write(l[i].PatternID);
            }
            double dblPatternCost = ecPattern.GetOutputSize();

            mcData.Reset();
            double dblDataCost = 0.0;

            foreach (QePatternInstance pi in l)
            {
                QeCharType tChar = pi.SingleCharType;
                if (tChar != null)
                {
                    char ch = vPassword[pi.Position];
                    if (!mcData.Write(tChar.TypeID, ch))
                    {
                        dblDataCost += pi.Cost;
                    }
                }
                else
                {
                    dblDataCost += pi.Cost;
                }
            }
            dblDataCost += mcData.GetOutputSize();

            return(dblPatternCost + dblDataCost);
        }
        private static double ComputePathCost(List <QePatternInstance> patternInstanceCollection,
                                              char[] password, EntropyEncoder ecPattern, MultiEntropyEncoder mcData)
        {
            ecPattern.Reset();
            for (var i = 0; i < patternInstanceCollection.Count; ++i)
            {
                ecPattern.Write(patternInstanceCollection[i].ThePatternId);
            }

            var dblPatternCost = ecPattern.GetOutputSize();

            mcData.Reset();
            var dblDataCost = 0.0;

            foreach (var parameterInstance in patternInstanceCollection)
            {
                QeCharType characterType = parameterInstance.SingleCharType;
                if (characterType != null)
                {
                    var character = password[parameterInstance.Position];
                    if (!mcData.Write(characterType.TypeId, character))
                    {
                        dblDataCost += parameterInstance.Cost;
                    }
                }
                else
                {
                    dblDataCost += parameterInstance.Cost;
                }
            }
            dblDataCost += mcData.GetOutputSize();

            return(dblPatternCost + dblDataCost);
        }
Пример #3
0
		private static double ComputePathCost(List<QePatternInstance> l,
			char[] vPassword, EntropyEncoder ecPattern, MultiEntropyEncoder mcData)
		{
			ecPattern.Reset();
			for(int i = 0; i < l.Count; ++i)
				ecPattern.Write(l[i].PatternID);
			double dblPatternCost = ecPattern.GetOutputSize();

			mcData.Reset();
			double dblDataCost = 0.0;
			foreach(QePatternInstance pi in l)
			{
				QeCharType tChar = pi.SingleCharType;
				if(tChar != null)
				{
					char ch = vPassword[pi.Position];
					if(!mcData.Write(tChar.TypeID, ch))
						dblDataCost += pi.Cost;
				}
				else dblDataCost += pi.Cost;
			}
			dblDataCost += mcData.GetOutputSize();

			return (dblPatternCost + dblDataCost);
		}