Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidSignature = errors.New("invalid signature")
ErrInvalidSignature is returned by Unsign when the provided token's signatuire is not valid.
var ErrShortToken = errors.New("token is too small to be valid")
ErrShortToken is returned by Unsign when the provided token's length is too short to be a vlaid token.
Functions ¶
Types ¶
type Sword ¶
Sword is a magical Wooden Sword to be used for protection, because it's dangerous out there... Also, it is the main struct used to sign and unsign data using this package.
func New ¶
New takes a secret key and returns a new Sword. If no Options are provided then minimal defaults will be used. NOTE: The key must be 64 bytes or less in size. If a larger key is provided it will be truncated to 64 bytes. func New(key []byte, o *Options) *Sword {
func (*Sword) Parse ¶
Parse will parse the []byte token returned from Sign based on the Sword Options into a Token struct. For this to work corectly the Sword Options need to match that of what was used when the token was initially created.