How do I use keygen?

Note that keygen is a helper function for generating valid keys for your subst_encrypt and subst_decrypt functions. You should not use keygen within subst_encrypt and subst_decrypt. Instead both of those functions take the key, generated previously by keygen, as a parameter.