Documentation ¶
Index ¶
- Variables
- func Compare(hash []byte, str string) error
- func CompareBytes(hash, bytes []byte) error
- func Hash(str string) ([]byte, error)
- func HashBytes(bytes []byte) ([]byte, error)
- func Issue(secret []byte, issuer, name string, key RawKey) (string, error)
- func MustHash(str string) []byte
- func MustHashBytes(bytes []byte) []byte
- func MustRand(n int) []byte
- func Rand(n int) ([]byte, error)
- type Base
- type Data
- type Key
- type KeyMeta
- type Notary
- type RawKey
- type Secret
Constants ¶
This section is empty.
Variables ¶
var ErrExpiredToken = errors.New("expired token")
ErrExpiredToken is returned if a token is expired but otherwise valid.
var ErrInvalidToken = errors.New("invalid token")
ErrInvalidToken is returned if a token is in some way invalid.
Functions ¶
func Compare ¶
Compare will safely compare the specified hash to its unhashed version and return nil if they match.
func CompareBytes ¶
CompareBytes will safely compare the specified hash to its unhashed version and return nil if they match.
func Hash ¶
Hash uses bcrypt to safely compute a hash. The returned hash can be converted to readable string.
func HashBytes ¶
HashBytes uses bcrypt to safely compute a hash. The returned hash can be converted to readable string.
func MustHashBytes ¶
MustHashBytes will call HashBytes and panic on errors.
Types ¶
type Key ¶
type Key interface { // Validate should validate the token. Validate() error // contains filtered or unexported methods }
Key is a structure used to encode a key.
type Notary ¶
type Notary struct {
// contains filtered or unexported fields
}
Notary is used to issue and verify tokens from keys.
func NewNotary ¶
NewNotary creates a new notary with the specified name and secret. It will panic if the name is missing or the specified secret is less that 16 bytes.