Ejemplo n.º 1
0
        public string ToAttribute()
        {
            string result;
            string finder    = FindMethod.ToString() != "Href" ? FindMethod.ToString() : "Url";
            string findvalue = FindValue.Replace("\"", "\\\"");

            if (string.IsNullOrEmpty(FindName))
            {
                result = "FindBy(" + finder + " = \"" + findvalue + "\")";
            }
            else
            {
                result = "FindBy(" + finder + " = \"" + FindName + "\", \"" + findvalue + "\")";
            }
            return(result);
        }
Ejemplo n.º 2
0
        public override string ToString()
        {
            string result;
            string finder    = FindMethod.ToString() != "Href" ? FindMethod.ToString() : "Url";
            string findvalue = "";

            try
            {
                findvalue = FindValue != null?FindValue.Replace("\"", "\\\"") : "";
            }
            catch (Exception)
            {
            }
            if (string.IsNullOrEmpty(FindName))
            {
                result = "Find.By" + finder + "(\"" + findvalue + "\")";
            }
            else
            {
                result = "Find.By" + finder + "(\"" + FindName + "\", \"" + findvalue + "\")";
            }
            return(result);
        }
Ejemplo n.º 3
0
        public void FindKey(string chiperText)
        {
            chiperText = chiperText.ToUpper();
            var repetitionPeriods = KasiskiMethod(chiperText);

            if (repetitionPeriods.Count == 0)
            {
                Console.WriteLine("Невозможно найти период. Невозможно взломать ключ");
            }
            else
            {
                var nod = FindNOD(repetitionPeriods.ToArray());
                var k   = 1;
                for (var m = nod; ; m = nod * k)
                {
                    if (m > chiperText.Length / m)
                    {
                        break;
                    }
                    char[,] strings = new char[chiperText.Length / m + 1, m];
                    for (int i = 0; i < chiperText.Length; i++)
                    {
                        int ii = i / m;
                        int ij = i - (ii * m);

                        strings[ii, ij] = chiperText[i];
                    }
                    var paswords = new List <string>();
                    paswords.Add("");
                    for (int i = 0; i < m; i++)
                    {
                        Dictionary <char, int> dict = new Dictionary <char, int>();

                        for (int j = 0; j < (chiperText.Length / m) + 1; j++)
                        {
                            if (dict.ContainsKey(strings[j, i]))
                            {
                                dict[strings[j, i]]++;
                            }
                            else
                            {
                                dict.Add(strings[j, i], 1);
                            }
                        }

                        var sortict = dict.OrderByDescending(x => x.Value)
                                      .ToDictionary(x => x.Key, x => x.Value);
                        var maxValue         = sortict.Values.Max();
                        var positionCandidat = new List <char>();

                        char sy = Languege.z == 33 ? 'О' : 'E';
                        foreach (var kvp in sortict)
                        {
                            if (kvp.Value < maxValue)
                            {
                                break;
                            }
                            else
                            {
                                positionCandidat.Add(kvp.Key);
                            }
                        }
                        if (positionCandidat.Count > 1)
                        {
                            var bufList = new List <string>(paswords);
                            for (var copy = 0; copy < positionCandidat.Count - 1; copy++)
                            {
                                paswords.AddRange(bufList);
                            }
                            var transition      = paswords.Count / positionCandidat.Count;
                            var candidatElement = 0;
                            for (var pos = 0; pos < paswords.Count; pos++)
                            {
                                if (pos != 0 && pos % transition == 0)
                                {
                                    candidatElement++;
                                }
                                int res = Languege.dictionary[positionCandidat[candidatElement]] -
                                          Languege.dictionary[sy];
                                paswords[pos] += FindValue.Findvalue(res + 1);
                            }
                        }
                        else
                        {
                            int res = Languege.dictionary[positionCandidat[0]] -
                                      Languege.dictionary[sy];
                            for (var pos = 0; pos < paswords.Count; pos++)
                            {
                                paswords[pos] += FindValue.Findvalue(res);
                            }
                        }
                    }
                    foreach (var password in paswords)
                    {
                        Add(password);
                    }
                    k += 1;
                }
            }
        }
Ejemplo n.º 4
0
        private void FindFeatures(IEnumerable <FeatureLayer> selectedLayers)
        {
            IsBusy = true;
            foreach (var layer in selectedLayers)
            {
                Task.Factory.StartNew(() =>
                {
                    Collection <Feature> features = new Collection <Feature>();
                    layer.SafeProcess(() =>
                    {
                        Collection <Feature> allFeatures = new Collection <Feature>();
                        allFeatures         = layer.QueryTools.GetAllFeatures(layer.GetDistinctColumnNames());
                        var queriedFeatures = allFeatures.Where(f =>
                        {
                            bool hasValue = f.ColumnValues.Values
                                            .Any(value => value.ToUpperInvariant().Contains(FindValue.ToUpperInvariant()));
                            return(hasValue);
                        });

                        foreach (var item in queriedFeatures)
                        {
                            features.Add(item);
                        }
                    });

                    FeatureLayerViewModel entity = new FeatureLayerViewModel {
                        LayerName = layer.Name
                    };
                    foreach (var tmpFeature in features)
                    {
                        entity.FoundFeatures.Add(new FeatureViewModel(tmpFeature, layer));
                    }

                    Application.Current.Dispatcher.BeginInvoke(() =>
                    {
                        if (!FeatureEntities.Any(f => f.LayerName == entity.LayerName) && entity.FoundFeatures.Count > 0)
                        {
                            FeatureEntities.Add(entity);
                            if (FeatureEntities.Count > 0 && FeatureEntities[0].FoundFeatures.Count > 0)
                            {
                                selectedEntity = FeatureEntities[0].FoundFeatures[0];
                                RaisePropertyChanged(() => SelectedDataView);
                            }
                        }
                        IsBusy = false;
                    }, DispatcherPriority.ApplicationIdle);
                });
            }
        }
Ejemplo n.º 5
0
        public void FindKey(string cText, string oText)
        {
            var numberLitera = Converter.ConvertWordToCode(cText);

            for (var del = 2; del <= cText.Length; del++)
            {
                if (cText.Length % del != 0)
                {
                    continue;
                }
                else
                {
                    var possiblePermutations = SetTransposition(new int[del], 0, del);
                    foreach (var perm in possiblePermutations)
                    {
                        var array = new double[cText.Length / del, del];
                        var pos   = 0;
                        for (var x = 0; x < del; x++)
                        {
                            for (var y = 0; y < cText.Length / del; y++)
                            {
                                array[y, x] = numberLitera[pos];
                                pos++;
                            }
                        }
                        var matrixArray = Matrix <double> .Build.DenseOfArray(array);

                        var ansverMatrix = DenseMatrix.Create(cText.Length / del, del, 0);
                        pos = 0;
                        foreach (var p in perm)
                        {
                            var column = matrixArray.Column(p);
                            ansverMatrix.SetColumn(pos, column.ToArray());
                            pos++;
                        }
                        string ans = "";
                        for (var y = 0; y < cText.Length / del; y++)
                        {
                            for (var x = 0; x < del; x++)
                            {
                                ans += Convert.ToString(FindValue.Findvalue(Convert.ToInt32(ansverMatrix[y, x]) % Languege.z));
                            }
                        }
                        if (ans.Contains(oText.ToUpper()))
                        {
                            Key.Add(perm);
                        }
                        #region
                        //var block = 0;
                        //var permIndex = 0;
                        //var decryption = new char[cText.Length];
                        //for (var w = 0; w < cText.Length; w++)
                        //{
                        //    decryption[w] = cText[perm[permIndex] + block];
                        //    permIndex++;
                        //    if ((w + 1) % del == 0 && w != 0)
                        //        block+=del;
                        //    if (permIndex == perm.Length)
                        //        permIndex = 0;
                        //}
                        ////TODO: Сделать из этого что-то нормальное
                        //var stringDecryption = Converter.ConvertArrayToString(decryption);
                        //if (stringDecryption.Contains(oText))
                        //    Key.Add(perm);
                        //if (Languege.dictionary.ContainsKey('А')) //Русский язык
                        //{
                        //    var dictionary = WordList.CreateFromFiles(@"Russian.dic", @"Russian.aff");
                        //    var suggestions = dictionary.Suggest(stringDecryption);
                        //    foreach (var s in suggestions)
                        //        Console.WriteLine(s);
                        //}
                        //else
                        //{

                        //}
                        #endregion
                    }
                }
            }
        }