public static CalculationResult StartCalculations(string input, MonoAlphabet alpha,
                                                          EncoderType encoderType, CodingType codingType, out IMonoAlphabet monoAlphabet)
        {
            var result = Empty;

            var alphabetInfo = "";

            if (alpha == MonoAlphabet.Auto)
            {
                var autoDetected = Alphabet.DetectMonoFromString(input);
                alphabetInfo = $"За вхідним повідомленням визначено алфавіт: " +
                               $"{MonoAlphabets.GetName(autoDetected.Item2)}";
                monoAlphabet = autoDetected.Item1;
            }
            else
            {
                alphabetInfo = $"Задано алфавіт: {MonoAlphabets.GetName(alpha)}";
                monoAlphabet = Alphabet.GetMono(alpha);
            }

            result.CalculationsPipeline.AddRange(new string[]
            {
                "  --  ",
                "Початок обчислень...",
                $"Тип шифрування: {EncodingTypes.GetName(encoderType)}",
                $"Тип операції: {CodingTypes.GetName(codingType)}",
                alphabetInfo,
                $"Повідомлення: {input}"
            });

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Erzeugt eine neue Liste.
        /// </summary>
        /// <param name="container">Der SI Bereich, in dem diese Liste gefunden wurde.</param>
        /// <param name="offset">Der Index des ersten Bytes dieser Liste in den Rohdaten des SI Bereichs.</param>
        /// <param name="length">Die Anzahl der Bytes für diese Liste.</param>
        public FrequencyList( IDescriptorContainer container, int offset, int length )
            : base( container, offset, length )
        {
            // Check for minimum length
            if (length < 1)
                return;

            // Attach to section
            Section section = container.Section;

            // Read the coding type
            CodingType = (CodingTypes) (section[offset + 0] & 0x3);

            // Load all
            for (length -= 1, offset += 1; length > 0; length -= 4, offset += 4)
            {
                // Not possible
                if (length < 4)
                    return;

                // Load the item
                Frequencies.Add( Tools.MergeBytesToDoubleWord( section[offset + 3], section[offset + 2], section[offset + 1], section[offset + 0] ) );
            }

            // Test
            m_Valid = true;
        }
        /// <summary>
        /// Erzeugt eine neue Liste.
        /// </summary>
        /// <param name="container">Der SI Bereich, in dem diese Liste gefunden wurde.</param>
        /// <param name="offset">Der Index des ersten Bytes dieser Liste in den Rohdaten des SI Bereichs.</param>
        /// <param name="length">Die Anzahl der Bytes für diese Liste.</param>
        public FrequencyList(IDescriptorContainer container, int offset, int length)
            : base(container, offset, length)
        {
            // Check for minimum length
            if (length < 1)
            {
                return;
            }

            // Attach to section
            Section section = container.Section;

            // Read the coding type
            CodingType = (CodingTypes)(section[offset + 0] & 0x3);

            // Load all
            for (length -= 1, offset += 1; length > 0; length -= 4, offset += 4)
            {
                // Not possible
                if (length < 4)
                {
                    return;
                }

                // Load the item
                Frequencies.Add(Tools.MergeBytesToDoubleWord(section[offset + 3], section[offset + 2], section[offset + 1], section[offset + 0]));
            }

            // Test
            m_Valid = true;
        }
        private void CaesarCalculatorControl_Load(object sender, EventArgs e)
        {
            MonoAlphabet = MonoAlphabets.Default().Alphabet;

            comboBox1.Items.AddRange(MonoAlphabets.GetAllNames());
            CalculationsTypeCmbBx.Items.AddRange(CodingTypes.GetAllNames());
            comboBox1.SelectedIndex             = 0;
            CalculationsTypeCmbBx.SelectedIndex = 0;
        }
 private void CalculationsTypeCmbBx_SelectedIndexChanged(object sender, EventArgs e)
 {
     CodingType = CodingTypes.GetCodingType(CalculationsTypeCmbBx.Text);
 }