def work_encode(source, destination, key):
    '''Encodes and saves a file.

    Creates buffers for a new file and a "quick key."
    Generates the "quick key."
    Encodes the old file onto the new file buffer.
    Writes the buffer to the destination.
    Closes the open files.'''
    new_file = ''
    encode_key = range(256)
    for index in range(256):
        encode_key[key[index][0]] = key[index][1]
    for line in source:
        for byte in line:
            new_file += chr(encode_key[ord(byte)])
    destination.write(new_file)
    source.close()
    destination.flush()
    destination.close()
Encodes and saves a file.

    Creates buffers for a new file and a "quick key."
    Generates the "quick key."
    Encodes the old file onto the new file buffer.
    Writes the buffer to the destination.
    Closes the open files.
recipes/Python/456374_Crypt/recipe-456374.py