示例#1
0
        private String CreateAlphabetOutput(int[] key, Alphabet ciphertext_alphabet)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < key.Length; i++)
            {
                sb.Append(ciphertext_alphabet.GetLetterFromPosition(key[i]));
            }

            return(sb.ToString());
        }
示例#2
0
        /// <summary>
        /// Convert text to string
        /// </summary>
        public string ToString(Alphabet alpha)
        {
            string res = "";

            for (int i = 0; i < this.text.Count; i++)
            {
                int letter = this.text[i];

                if (letter >= 0)
                {
                    if (this.caseSensitive == false && this.orgCapital[i] == true)
                    {
                        res += alpha.GetLetterFromPosition(letter).ToUpper();
                    }
                    else
                    {
                        res += alpha.GetLetterFromPosition(letter);
                    }
                }
                else
                {
                    if (this.invalidCharProcess == 0)
                    {
                        res += this.notInAlphabet[(-1) * letter - 1];
                    }
                    else if (this.invalidCharProcess == 1)
                    {
                        res += " ";
                    }
                    else if (this.invalidCharProcess == 2)
                    {
                        res += "?";
                    }
                }
            }

            return(res);
        }