def auto_encrypt_str(string, chain_size, plain_text='',
                     encoding='utf-8', errors='ignore'):
    """Encrypt string with automatically generated key and primer.

    This function automates key and primer creation and encrypts the
    string with them. The two arguments following the data allow some
    simple customizations of the key and primer generation process."""
    string, plain_text = string.encode(encoding, errors), \
                         plain_text.encode(encoding, errors)
    key = Key.new(set(string) - set(plain_text), chain_size)
    primer = Primer.new(key)
    return Encrypter(key, primer).process(string)\
           .decode(encoding, errors), key, primer
Encrypt string with automatically generated key and primer.

    This function automates key and primer creation and encrypts the
    string with them. The two arguments following the data allow some
    simple customizations of the key and primer generation process.
recipes/Python/578075_Markov_Encryption_Module/recipe-578075.py