(pt, key, symbols="ABCDEFGHIJKLMNOPQRSTUVWXYZ")
return "".join(C)
r"""
    Performs the affine cipher encryption on plaintext ``pt``, and returns the ciphertext.

    Encryption is based on the map `x \rightarrow ax+b` (mod `26`). Decryption is based on
    the map `x \rightarrow cx+d` (mod `26`), where `c = a^{-1}` (mod `26`) and
    `d = -a^{-1}c` (mod `26`). (In particular, for the map to be invertible,
    we need `\mathrm{gcd}(a, 26) = 1.`)

    Notes
    =====

    This is a straightforward generalization of the shift cipher.

    ALGORITHM:

        INPUT:

            ``a, b``: a pair integers, where ``gcd(a, 26) = 1`` (the secret key)

            ``m``: string of upper-case letters (the plaintext message)

        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 ``L1`` of corresponding
               integers.
            2. Compute from the list ``L1`` a new list ``L2``, given by replacing
               ``x`` by ``a*x + b (mod 26)``, for each element ``x`` in ``L1``.
            3. Compute from the list ``L2`` a string ``c`` of corresponding
               letters.

    Examples
    ========

    >>> from sympy.crypto.crypto import encipher_affine
    >>> pt = "GONAVYBEATARMY"
    >>> encipher_affine(pt, (1, 1))
    'HPOBWZCFBUBSNZ'
    >>> encipher_affine(pt, (1, 0))
    'GONAVYBEATARMY'
    >>> pt = "GONAVYBEATARMY"
    >>> encipher_affine(pt, (3, 1))
    'TROBMVENBGBALV'
    >>> ct = "TROBMVENBGBALV"
    >>> encipher_affine(ct, (9, 17))
    'GONAVYBEATARMY'
r"""
    Performs the affine cipher encryption on plaintext ``pt``, and returns the ciphertext.
r Performs the affine cipher encryption on plaintext pt and returns the ciphertext .
def encipher_affine(pt, key, symbols="ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
    r"""
    Performs the affine cipher encryption on plaintext ``pt``, and returns the ciphertext.

    Encryption is based on the map `x \rightarrow ax+b` (mod `26`). Decryption is based on
    the map `x \rightarrow cx+d` (mod `26`), where `c = a^{-1}` (mod `26`) and
    `d = -a^{-1}c` (mod `26`). (In particular, for the map to be invertible,
    we need `\mathrm{gcd}(a, 26) = 1.`)

    Notes
    =====

    This is a straightforward generalization of the shift cipher.

    ALGORITHM:

        INPUT:

            ``a, b``: a pair integers, where ``gcd(a, 26) = 1`` (the secret key)

            ``m``: string of upper-case letters (the plaintext message)

        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 ``L1`` of corresponding
               integers.
            2. Compute from the list ``L1`` a new list ``L2``, given by replacing
               ``x`` by ``a*x + b (mod 26)``, for each element ``x`` in ``L1``.
            3. Compute from the list ``L2`` a string ``c`` of corresponding
               letters.

    Examples
    ========

    >>> from sympy.crypto.crypto import encipher_affine
    >>> pt = "GONAVYBEATARMY"
    >>> encipher_affine(pt, (1, 1))
    'HPOBWZCFBUBSNZ'
    >>> encipher_affine(pt, (1, 0))
    'GONAVYBEATARMY'
    >>> pt = "GONAVYBEATARMY"
    >>> encipher_affine(pt, (3, 1))
    'TROBMVENBGBALV'
    >>> ct = "TROBMVENBGBALV"
    >>> encipher_affine(ct, (9, 17))
    'GONAVYBEATARMY'

    """
    symbols = "".join(symbols)
    A = alphabet_of_cipher(symbols)
    n = len(A)
    k1 = key[0] # multiplicative coeff "a"
    k2 = key[1] # additive coeff "b"
    L = cycle_list(k2, n)
    C = [A[(k1*A.index(pt[i]) + k2) % n] for i in range(len(pt))]
    return "".join(C)
def encipher_affine ( pt , key , symbols = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ) : symbols = "" . join ( symbols ) A = alphabet_of_cipher ( symbols ) n = len ( A ) k1 = key [ 0 ] # multiplicative coeff "a" k2 = key [ 1 ] # additive coeff "b" L = cycle_list ( k2 , n ) C = [ A [ ( k1 * A . index ( pt [ i ] ) + k2 ) % n ] for i in range ( len ( pt ) ) ] return "" . join ( C )