﻿using System;

namespace Ciphers
{
    static class CaesarCipher
    {
        private const String LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        private const String letters = "abcdefghijklmnopqrstuvwxyz";

        private static String translated;

        private static int num;

        public static String Shift(String message, byte key)
        {
            translated = "";
            foreach (char c in message)
            {
                if (LETTERS.IndexOf(c) != -1)
                {
                    num = LETTERS.IndexOf(c) + key;
                    if (num >= LETTERS.Length)
                        num -= LETTERS.Length;
                    translated += LETTERS[num];
                }
                else if (letters.IndexOf(c) != -1)
                {
                    num = letters.IndexOf(c) + key;
                    if (num >= letters.Length)
                        num -= letters.Length;
                    translated += letters[num];
                }
                else
                {
                    translated += c;
                }
            }
            return translated;
        }

    }
}
