moved the token encoding from httpcontext to utils since we want to use it from other sources than http requests...