def encrypt(plaintext, cipher, shift):
    """
    Caesar encryption of a plaintext using a shifted cipher.

    You can specify a positiv shift to rotate the cipher to the right
    and using a negative shift to rotate the cipher to the left.

    :param plaintext: the text to encrypt.
    :param cipher: set of characters, shifted in a directed to used for character substitution.
    :param shift: offset to rotate cipher.
    :returns: encrypted plaintext (ciphertext).

    See: https://en.wikipedia.org/wiki/Caesar_cipher
    Example:

    >>> encrypt("hello world", "abcdefghijklmnopqrstuvwxyz ", 1)
    'gdkknzvnqkc'
    >>> encrypt("hello world", "abcdefghijklmnopqrstuvwxyz ", -1)
    'ifmmpaxpsme'
    """
    # calculating shifted cipher
    shifted_cipher = cipher
    if shift > 0:
        while shift > 0:
            shifted_cipher = shifted_cipher[-1] + shifted_cipher[0:len(shifted_cipher) - 1]
            shift -= 1
    else:
        while shift < 0:
            shifted_cipher = shifted_cipher[1:] + shifted_cipher[0]
            shift += 1

    return "".join([shifted_cipher[cipher.index(character)] for character in plaintext])