functions for generating and checking email token