コード例 #1
0
        public static void Decrypt()
        {
            var    userInput          = new DecryptionUserInput();
            var    intermediateSteps  = new DecryptIntermediateSteps(userInput);
            string decryptedPlainText = DecryptPlainText(userInput, intermediateSteps);

            Console.WriteLine("Decrypted plaintext:");
            Console.WriteLine(decryptedPlainText);
        }
コード例 #2
0
            public DecryptIntermediateSteps(DecryptionUserInput userInput)
            {
                (string, string) DecryptBookIndexPositions()
                {
                    string combinedEncryptedBookIndexPositions =
                        userInput.EncryptedBookGroupStart + userInput.EncryptedBookGroupEnd;

                    // Get a digit series of the word lengths in B.
                    string componentBWordLengths = userInput.ComponentB
                                                   .Split(' ')
                                                   .Aggregate("", (current, word) => current + word.Length);

                    // Resize component B's word lengths to the combined encrypted book index positions using the LFG.
                    string resizedComponentBWordLengths =
                        ResizeUsingLaggedFibonacciGenerator(componentBWordLengths, combinedEncryptedBookIndexPositions.Length);

                    // Decrypt the book index positions by subtracting component B's resized word lengths.
                    string decryptedCombinedBookIndexPositions = IndividualDigitsModulus10Calculation(
                        combinedEncryptedBookIndexPositions,
                        resizedComponentBWordLengths,
                        IndividualDigitsModulus10Operation.Subtract);

                    return(decryptedCombinedBookIndexPositions[..7], decryptedCombinedBookIndexPositions[7..14]);