Exemplo n.º 1
0
        /// <summary>
        /// Called every time this plugin is run in the workflow execution.
        /// </summary>
        public void Execute()
        {
            ProgressChanged(0, 1);
            try
            {
                if (!CheckAlphabetLength())
                {
                    return;
                }
                separator = ChooseSeparator(settings.Separator);
                messages  = Messages.Split(new[] { separator }, StringSplitOptions.None);

                if (!CheckMessages())
                {
                    return;
                }
            }
            catch (Exception ex)
            {
                GuiLogMessage("ExecuteChecks: " + ex.Message, NotificationLevel.Error);
            }

            ClearDisplay();

            UpdateDisplayStart();

            try
            {
                ThreadingHelper threadingHelper = new ThreadingHelper(threads, this);
                for (int j = 1; j <= threads; j++)
                {
                    Thread thread = new Thread(AlgorithmThread);
                    ThreadList.Add(thread);
                    thread.IsBackground = true;
                    thread.Start(new object[] { keylength, messages, j, threadingHelper, settings });
                    LogText += Environment.NewLine + "Starting Thread: " + j;
                }
                foreach (Thread t in ThreadList)
                {
                    t.Join();
                }
            }
            catch (Exception ex)
            {
                GuiLogMessage("Execute: " + ex.Message, NotificationLevel.Error);
            }
        }
Exemplo n.º 2
0
 private void AlgorithmThread(object parametersObject)
 {
     try
     {
         object[]               parameters      = (object[])parametersObject;
         int                    i               = (int)parameters[0];
         String[]               messages        = (string[])parameters[1];
         int                    j               = (int)parameters[2];
         ThreadingHelper        threadingHelper = (ThreadingHelper)parameters[3];
         ADFGVXANalyzerSettings settings        = (ADFGVXANalyzerSettings)parameters[4];
         Algorithm              a               = new Algorithm(i, messages, log, j, threadingHelper, settings, this);
         a.SANgramsIC();
     }
     catch (ThreadAbortException)
     {
         //do nothing; analysis aborts threads to stop them :-/
     }
     catch (Exception ex)
     {
         GuiLogMessage(string.Format(Properties.Resources.ExceptionDuringThread, ex.Message), NotificationLevel.Error);
     }
 }
Exemplo n.º 3
0
        public Algorithm(int keyLength, String[] messages, Logger log, int taskId, ThreadingHelper threadingHelper, ADFGVXANalyzerSettings settings, ADFGVXAnalyzer analyzer)
        {
            this.analyzer        = analyzer;
            this.threadingHelper = threadingHelper;
            this.taskId          = taskId;
            this.log             = log;
            this.language        = settings.Language;
            this.deviation       = settings.Deviation;
            this.restarts        = settings.Restarts;
            this.keyLength       = keyLength;
            ciphers = new ADFGVXVector[messages.Length];
            int totalPlainLength = 0;
            int maxPlainLength   = 0;

            for (int m = 0; m < messages.Length; m++)
            {
                ciphers[m]        = new ADFGVXVector(messages[m].Replace(" ", ""), false);
                totalPlainLength += ciphers[m].length / 2;
                maxPlainLength    = Math.Max(maxPlainLength, ciphers[m].length / 2);
            }
            allPlain      = new Alphabet36Vector(totalPlainLength, true);
            plain         = new Alphabet36Vector(maxPlainLength, false);
            interimCipher = new ADFGVXVector(maxPlainLength * 2, false);
        }