Short Length Authentication Token

Viewed 13156

I want to encode the userdetails to a token and at the server side i need to decode the details. I used JWT token concept.It works perfect. But the problem is that I need token having length less than 10 characters according to the business requirement.JWT token is always a large length token. Is there any technique to limit the length of JWT. Or is there any other library available for short length token encoding?. Please anyone help me out of this

3 Answers

JWT has 3 parts,

  1. The header - which has info of which algos are used for signing and encoding
  2. the body - which is a base64 encoding of data you want to send
  3. The signature- which is HS256 hash(default) to ensure no tampering has been done.

Now if you need a smaller token you can write your own impl for tokens. With a custom impl you can straight away skip the head as you can have some default hashing algo for your project. Second in the body you can just send the id and have all info being later derived from it. For the third part Hashing in theory atleast can give you a fixed length hash for any length string, so if you find a hashing module with sufficient github stars that lets you set the hash size you're golden.

Related