Iss3

Fix of issue 3.

Decode now actually decodes the token.
Encode makes sure token is of length 0-8 bytes. If the token is too long, it is truncated. A token length of 8 is written and first 8 bytes of token are written.