(pt, key, symbols="ABCDEFGHIJKLMNOPQRSTUVWXYZ")
return "".join([A[i % N] for i in C])
r"""
    Performs the Hill cipher encryption on plaintext ``pt``, and returns the ciphertext.

    Notes
    =====

    The Hill cipher [1]_, invented by Lester S. Hill in the 1920's [2]_,
    was the first polygraphic cipher in which it was practical (though barely)
    to operate on more than three symbols at once. The following discussion assumes
    an elementary knowledge of matrices.

    First, each letter is first encoded as a number. We assume here that
    "A" `\leftrightarrow` 0, "B" `\leftrightarrow` 1, ..., "Z" `\leftrightarrow` 25.
    We denote the integers `\{0, 1, ..., 25\}`
    by `Z_{26}`. Suppose your message m consists of `n` capital letters, with no spaces.
    This may be regarded an `n`-tuple M of elements of `Z_{26}`. A key in the Hill cipher
    is a `k x k` matrix `K`, all of whose entries are in `Z_{26}`, such that the matrix
    `K` is invertible (ie, that the linear transformation `K: Z_{26}^k \rightarrow Z_{26}^k`
    is one-to-one).

    ALGORITHM:

        INPUT:

            ``key``: a `k x k` invertible matrix `K`, all of whose entries are in `Z_{26}`

            ``m``: string of `n` upper-case letters (the plaintext message)
            (Note: Sage assumes that `n` is a multiple of `k`.)

        OUTPUT:

            ``c``: string of upper-case letters (the ciphertext message)

        STEPS:
            0. Identify the alphabet A, ..., Z with the integers 0, ..., 25.
            1. Compute from the string ``m`` a list ``L`` of corresponding
               integers. Let ``n = len(L)``.
            2. Break the list ``L`` up into ``t = ceiling(n/k)`` sublists
               ``L_1``, ..., ``L_t`` of size ``k`` (where the last list might be
               "padded" by 0's to ensure it is size ``k``).
            3. Compute new list ``C_1``, ..., ``C_t`` given by ``C[i] = K*L_i``
               (arithmetic is done mod 26), for each ``i``.
            4. Concatenate these into a list ``C = C_1 + ... + C_t``.
            5. Compute from ``C`` a string ``c`` of corresponding letters.
               This has length ``k*t``.

    References
    ==========

    .. [1] en.wikipedia.org/wiki/Hill_cipher
    .. [2] Lester S. Hill, Cryptography in an Algebraic Alphabet, The American
       Mathematical Monthly Vol.36, June-July 1929, pp.306-312.

    Examples
    ========

    >>> from sympy.crypto.crypto import encipher_hill
    >>> from sympy import Matrix
    >>> pt = "meet me on monday"
    >>> key = Matrix([[1, 2], [3, 5]])
    >>> encipher_hill(pt, key)
    'UEQDUEODOCTCWQ'
    >>> pt = "meet me on tuesday"
    >>> encipher_hill(pt, key)
    'UEQDUEODHBOYDJYU'
    >>> pt = "GONAVYBEATARMY"
    >>> key = Matrix([[1, 0, 1], [0, 1, 1], [2, 2, 3]])
    >>> encipher_hill(pt, key)
    'TBBYTKBEKKRLMYU'
r"""
    Performs the Hill cipher encryption on plaintext ``pt``, and returns the ciphertext.
r Performs the Hill cipher encryption on plaintext pt and returns the ciphertext .
def encipher_hill(pt, key, symbols="ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
    r"""
    Performs the Hill cipher encryption on plaintext ``pt``, and returns the ciphertext.

    Notes
    =====

    The Hill cipher [1]_, invented by Lester S. Hill in the 1920's [2]_,
    was the first polygraphic cipher in which it was practical (though barely)
    to operate on more than three symbols at once. The following discussion assumes
    an elementary knowledge of matrices.

    First, each letter is first encoded as a number. We assume here that
    "A" `\leftrightarrow` 0, "B" `\leftrightarrow` 1, ..., "Z" `\leftrightarrow` 25.
    We denote the integers `\{0, 1, ..., 25\}`
    by `Z_{26}`. Suppose your message m consists of `n` capital letters, with no spaces.
    This may be regarded an `n`-tuple M of elements of `Z_{26}`. A key in the Hill cipher
    is a `k x k` matrix `K`, all of whose entries are in `Z_{26}`, such that the matrix
    `K` is invertible (ie, that the linear transformation `K: Z_{26}^k \rightarrow Z_{26}^k`
    is one-to-one).

    ALGORITHM:

        INPUT:

            ``key``: a `k x k` invertible matrix `K`, all of whose entries are in `Z_{26}`

            ``m``: string of `n` upper-case letters (the plaintext message)
            (Note: Sage assumes that `n` is a multiple of `k`.)

        OUTPUT:

            ``c``: string of upper-case letters (the ciphertext message)

        STEPS:
            0. Identify the alphabet A, ..., Z with the integers 0, ..., 25.
            1. Compute from the string ``m`` a list ``L`` of corresponding
               integers. Let ``n = len(L)``.
            2. Break the list ``L`` up into ``t = ceiling(n/k)`` sublists
               ``L_1``, ..., ``L_t`` of size ``k`` (where the last list might be
               "padded" by 0's to ensure it is size ``k``).
            3. Compute new list ``C_1``, ..., ``C_t`` given by ``C[i] = K*L_i``
               (arithmetic is done mod 26), for each ``i``.
            4. Concatenate these into a list ``C = C_1 + ... + C_t``.
            5. Compute from ``C`` a string ``c`` of corresponding letters.
               This has length ``k*t``.

    References
    ==========

    .. [1] en.wikipedia.org/wiki/Hill_cipher
    .. [2] Lester S. Hill, Cryptography in an Algebraic Alphabet, The American
       Mathematical Monthly Vol.36, June-July 1929, pp.306-312.

    Examples
    ========

    >>> from sympy.crypto.crypto import encipher_hill
    >>> from sympy import Matrix
    >>> pt = "meet me on monday"
    >>> key = Matrix([[1, 2], [3, 5]])
    >>> encipher_hill(pt, key)
    'UEQDUEODOCTCWQ'
    >>> pt = "meet me on tuesday"
    >>> encipher_hill(pt, key)
    'UEQDUEODHBOYDJYU'
    >>> pt = "GONAVYBEATARMY"
    >>> key = Matrix([[1, 0, 1], [0, 1, 1], [2, 2, 3]])
    >>> encipher_hill(pt, key)
    'TBBYTKBEKKRLMYU'

    """
    symbols = "".join(symbols)
    A = alphabet_of_cipher(symbols)
    N = len(A)   # normally, 26
    k = key.cols
    pt0 = [x.capitalize() for x in pt if x.isalnum()]
    P = [A.index(x) for x in pt0]
    n = len(P)
    m = n//k
    if n > m*k:
        P = P + [0]*(n - m*k)
        m = m + 1
    C = [list(key*Matrix(k, 1, [P[i] for i in range(k*j, k*(j + 1))])) for j in range(m)]
    C = flatten(C)
    return "".join([A[i % N] for i in C])
def encipher_hill ( pt , key , symbols = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ) : symbols = "" . join ( symbols ) A = alphabet_of_cipher ( symbols ) N = len ( A ) # normally, 26 k = key . cols pt0 = [ x . capitalize ( ) for x in pt if x . isalnum ( ) ] P = [ A . index ( x ) for x in pt0 ] n = len ( P ) m = n // k if n > m * k : P = P + [ 0 ] * ( n - m * k ) m = m + 1 C = [ list ( key * Matrix ( k , 1 , [ P [ i ] for i in range ( k * j , k * ( j + 1 ) ) ] ) ) for j in range ( m ) ] C = flatten ( C ) return "" . join ( [ A [ i % N ] for i in C ] )