Documentation ¶
Overview ¶
Package itsrisky is a library to generate data signature powered by hmac and a hash algorithm(default by SHA1)
itsrisky provide some sign helper method for web application
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateSecretKey ¶
if you don't have a long and strong enough secret key,use this method to generate a n length strong secret key quick and safe
func StringBytes ¶
return GoString's buffer slice(enable modify string)
Types ¶
type ErrBadData ¶
type ErrBadData struct { Data interface{} Err error }
Err about data format invalid
func (*ErrBadData) Error ¶
func (e *ErrBadData) Error() string
type ErrDataExpired ¶
type ErrDataExpired struct {
// contains filtered or unexported fields
}
Err about data has been expired
func (*ErrDataExpired) Error ¶
func (e *ErrDataExpired) Error() string
type ErrDataTooShort ¶
type ErrDataTooShort struct {
DataLength int
}
Err about invalid data length
func (*ErrDataTooShort) Error ¶
func (e *ErrDataTooShort) Error() string
type Serialization ¶
type Serialization struct { SecretKey string Hash hash.Hash // contains filtered or unexported fields }
serialization to provide a serializer with web-friendly
func (*Serialization) Dumps ¶
func (s *Serialization) Dumps(in interface{}, expiredTime time.Duration) (string, error)
dump the given data into json and generate a signature with data and deadline information
func (*Serialization) Loads ¶
func (s *Serialization) Loads(data string, receiveData interface{}) (err error)
validate given signed string and check whether the data is expired, return data if string is well signed
func (*Serialization) WithSalt ¶
func (s *Serialization) WithSalt(salt string)
add salt to serialization
type Signer ¶
common signer to provide normal sign method
type SignerWithTimeout ¶
signer to provide sign method with timeout