Exemple #1
0
        public static string encryptText(int keylen)
        {
            key = GetKey(keylen);
            var text = TextPreparing.GetCleanText();

            for (int i = 0; i < text.Length; i++)
            {
                int h = key[i % keylen] - 1072;
                cypherText += Convert.ToChar(((Convert.ToInt32(text[i]) % 1072 + h) % 32) + 1072);
            }
            return(cypherText);
        }
Exemple #2
0
        public static string GetKey(int len)
        {
            string genKey   = "";
            var    alphabet = TextPreparing.Alphabet();
            var    rnd      = new Random(DateTime.Now.Millisecond);

            for (int i = 0; i < len; i++)
            {
                int ticks = rnd.Next(0, 32);
                genKey += alphabet[ticks];
            }
            return(genKey);
        }
Exemple #3
0
        public static Dictionary <char, int> countSymbol(string cypheText)
        {
            var alphabet  = TextPreparing.Alphabet();
            var monograms = new Dictionary <char, int>();

            foreach (var letter in alphabet)
            {
                monograms.Add(letter, 0);
            }
            foreach (var letter in cypheText)
            {
                monograms[letter]++;
            }
            return(monograms);
        }