// final function
        public string Encrypt(string plainText, string key)
        {
            string localMessage;
            string localKey;
            char[,] localMatrix;
            string[] localDiagrams;
            string localCipher;
            Utilities utilityObject = new Utilities();
            char[] charsToNumbersObject = utilityObject.getCharsToNumbersMap();

            //filter message and key
            localMessage = utilityObject.messageFilter(plainText);
            localKey = utilityObject.messageFilter(key);

            // working on key >>

            // remove key duplication
            localKey = removeDuplicates(localKey);
            // matrix generation
            localMatrix = matrixFilling(localKey, charsToNumbersObject);

            // working on message >>

            // message handling
            localMessage = plainTextHandling(localMessage);
            // convert message to diagrams
            localDiagrams = toDiagrams(localMessage);
            // generating Cipher
            localCipher = diagramsMapping(localDiagrams, localMatrix);
            // to Capital Letters
            localCipher = utilityObject.toCapitalLetters(localCipher);

            return localCipher;
        }
Exemple #2
0
        public string Encrypt(string PlainText, string key)
        {
            string output = "";

            utilityObject.setCharsToCharsMap(key);
            charsToCharsObject = utilityObject.getCharsToCharsMap();
            PlainText          = utilityObject.messageFilter(PlainText);
            for (int i = 0; i < PlainText.Length; i++)
            {
                output += charsToCharsObject[(int)PlainText[i] - 97];
            }

            return(output);
        }
Exemple #3
0
        public string Encrypt(string message, string key)
        {
            int    tmp;
            string output = "";

            message = utilityObject.messageFilter(message);
            for (int i = 0; i < message.Length; i++)
            {
                tmp     = ((int)charsToNumbersObject[(int)message[i] - 97] + Convert.ToInt32(key) - 97) % 26;
                output += charsToNumbersObject[tmp];
            }
            output = utilityObject.toCapitalLetters(output);

            return(output);
        }
        public string Decrypt(string CipherText, string key)
        {
            string localMessage;
            string localKey;

            char[,] localMatrix;
            string[]  localDiagrams;
            string    localCipher;
            Utilities utilityObject = new Utilities();

            char[] charsToNumbersObject = utilityObject.getCharsToNumbersMap();


            //filter message and key
            localMessage = utilityObject.messageFilter(CipherText);
            localKey     = utilityObject.messageFilter(key);

            // working on key >>

            // remove key duplication
            localKey = removeDuplicates(localKey);
            // matrix generation
            localMatrix = matrixFilling(localKey, charsToNumbersObject);

            // working on message >>

            // message handling
            localMessage = plainTextHandling(localMessage);
            // convert message to diagrams
            localDiagrams = toDiagrams(localMessage);
            // generating Cipher
            localCipher = diagramsMappingDec(localDiagrams, localMatrix);
            // localCipher = diagramsMapping(localDiagrams, localMatrix);
            // to Capital Letters
            localCipher = utilityObject.toCapitalLetters(localCipher);

            return(localCipher);
        }