コード例 #1
0
        // a, b - lowercase only!
        public static int GetShift(char a, char b)
        {
            CaesarEncoder CE = new CaesarEncoder();
            int beginLetter = 0;
            int endLetter = 0;
            int res;

            foreach (var letter in CE._dictEn)
            {
                if (letter == a)
                    break;
                beginLetter++;
            }
            foreach (var letter in CE._dictEn)
            {
                if (letter == b)
                    break;
                endLetter++;
            }

            if (endLetter >= beginLetter)
            {
                res = endLetter - beginLetter;
            }
            else
            {
                res = (int)eVals.eEnAlphNum - beginLetter + endLetter;
            }

            return res;
        }
コード例 #2
0
 public static string EncodeCaesar(int shift, string inStr)
 {
     CaesarEncoder CCLogic = new CaesarEncoder(shift, inStr);
     return CCLogic.ShiftString();
 }