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)
- func UnsafeFastHash()
- type Base
- type Key
- type Meta
- type Notary
- type RawKey
- type Secret
Constants ¶
This section is empty.
Variables ¶
var ErrExpiredToken = xo.BF("expired token")
ErrExpiredToken is returned if a token is expired but otherwise valid.
var ErrInvalidToken = xo.BF("invalid token")
ErrInvalidToken is returned if a token is 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.
func UnsafeFastHash ¶ added in v0.32.0
func UnsafeFastHash()
UnsafeFastHash can be called to set the minimum allowed hash cost. This should only be used for speeding up automated tests.
Types ¶
type Base ¶
Base can be embedded in a struct to turn it into a key.
func (*Base) GetAccessor ¶ added in v0.28.0
GetAccessor implements the Key interface.
type Meta ¶
type Meta struct { // The key name. Name string // The key expiry. Expiry time.Duration // The accessor. Accessor *stick.Accessor }
Meta contains meta information about 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 than 16 bytes.