Documentation ¶
Overview ¶
Package hmacsha provides a simple token implementation using the hmac-sha256 algorithm.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Token ¶
Token implements a simple abstraction around generating tokens using the hmac-sha256 algorithm.
func FromKey ¶
FromKey will return a new token that is constructed using the specified secret and key.
Note: The secret and the token key should both at least have a length of 16 characters to be considered unguessable.
func Generate ¶
Generate will return a new token that is constructed using the specified secret and random key of the specified length.
Note: The secret and the to be generated token key should both at least have a length of 16 characters to be considered unguessable.
func MustGenerate ¶
MustGenerate will generate a token using Generate and panic instead of returning an error.
Note: The cryptographically secure pseudo-random number generator provided by the operating system may fail. However, such a fail would mean that something seriously must be wrong with the machine running this code.
func (*Token) Equal ¶
Equal returns true then the specified signature is the same as the tokens signature.
Note: This method should be used over just comparing the byte slices as it computed in constant time and limits certain attacks.
func (*Token) SignatureString ¶
SignatureString returns a string (base64) representation of the signature.