Caesar Ciphers are one of the most basic forms of encryption. It consists of a message and a key, and it shifts the letters of the message for the value of the key. 

Read more about it here: https://en.wikipedia.org/wiki/Caesar_cipher


## Your task

Your task is to create a function encryptor that takes 2 arguments - key and message - and returns the encrypted message.

Make sure to only shift letters, and be sure to keep the cases of the letters the same. All punctuation, numbers, spaces, and so on should remain the same. 

Also be aware of keys greater than 26 and less than -26. There's only 26 letters in the alphabet!

## Examples

A message `'Caesar Cipher'` and a key of `1` returns `'Dbftbs Djqifs'`.

A message `'Caesar Cipher'` and a key of `-1` returns `'Bzdrzq Bhogdq'`.

Difficulty: introductory

Starter code:

def encryptor(key, message):
	

Solutions:
from string import maketrans as mt, ascii_lowercase as lc, ascii_uppercase as uc
def encryptor(key, message):
    key %= 26
    return message.translate(mt(lc+uc, lc[key:]+lc[:key]+uc[key:]+uc[:key]))

def encryptor(key, message):
    upper_alpha = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    lower_alpha = list("abcdefghijklmnopqrstuvwxyz")

    cipher = ""
    for x in message:
        if x in upper_alpha:
            cipher += upper_alpha[(upper_alpha.index(x) + key) % 26] 
        elif x in lower_alpha:
            cipher += lower_alpha[(lower_alpha.index(x) + key) % 26]
        else: 
            cipher += x
    return cipher

from string import ascii_lowercase as l, ascii_uppercase as u

def encryptor(key, message):
    process = lambda x, abc: x in abc and abc[(abc.index(x) + key) % 26]
    return ''.join(process(c, l) or process(c, u) or c for c in message)

def encryptor(key, message):
    #Program me!
    key  = key % 26
    result = ''
    for c in message:
        if c >= 'A' and c <= 'Z':
            result += chr(((ord(c) - ord('A')) + key) % 26 + ord('A'))
        elif c >= 'a' and c <= 'z':
            result += chr(((ord(c) - ord('a')) + key) % 26 + ord('a'))
        else:
            result += c
    return result

def encryptor (key, mess):
    lst = []
    for i in mess:
        if i.isalpha():
            C = 97 - 32 * i.isupper()
            lst.append (chr ((ord (i) - C + key)%26 + C))
        else:
            lst.append (i)
    return ''.join (lst)

table = "".join(map(chr, range(65, 91))) * 2
table += table.lower()

def encryptor(key, message):
    key %= 26
    result = ""
    for c in message:
        if c in table:
            result += table[table.index(c) + key]
        else:
            result += c
    return result

def encryptor(key, message):
  table = (''.join(map(chr, list(range(97, 123)))) * 2) + (''.join(map(chr, list(range(65, 91)))) * 2)
  return ''.join([table[table.index(c) + (key % 26)] if c in table else c for c in message])


import string

def encryptor(key, message):
    transtab = string.maketrans(
        string.ascii_letters,
        (string.ascii_lowercase * 2)[key%26:key%26+26] + (string.ascii_uppercase * 2)[key%26:key%26+26])
    return message.translate(transtab)

def encryptor(key, message):
    mod = key % 26
    if mod == 0: return message
    upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
    lower = 'abcdefghijklmnopqrstuvwxyz'
    code = []
    for char in message:
        if char.isupper():
            code.append(upper[(upper.find(char) + mod)%26])
        elif char.islower():
            code.append(lower[(lower.find(char) + mod)%26])
        else:
            code.append(char)
    return ''.join(code)

from string import ascii_lowercase as l, ascii_uppercase as u
a, r = f"{l}{u}", lambda s, m: f"{s[m:]}{s[:m]}"

def encryptor(k, m):
    return m.translate(str.maketrans(a, "".join(r(s, k % 26) for s in (l, u))))

def encryptor(key, msg):
    r = ''
    for i in msg:
        if i.isalpha():
            base = 65 if i.isupper() else 97
            r += chr(base + (ord(i)+key - base) % 26)
        else:
            r += i
    return r