Documentation
¶
Index ¶
- func CreateSolutionPayload(algorithm, challenge, salt string, number int, hmacKey string) (string, error)
- func SolveChallenge(challenge *Challenge, hmacKey string, maxAttempts int) (string, error)
- func ValidateChallenge(challenge *Challenge, hmacKey string) bool
- func VerifySolution(payload, hmacKey string, checkExpires bool) (bool, error)
- type Challenge
- type ChallengeOptions
- type CodeChallenge
- type Solution
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateSolutionPayload ¶
func CreateSolutionPayload(algorithm, challenge, salt string, number int, hmacKey string) (string, error)
CreateSolutionPayload creates a solution payload (for testing)
func SolveChallenge ¶
SolveChallenge finds a solution to a challenge (for testing)
func ValidateChallenge ¶
ValidateChallenge validates a challenge structure
Types ¶
type Challenge ¶
type Challenge struct {
Algorithm string `json:"algorithm"`
Challenge string `json:"challenge"`
MaxNumber int `json:"maxNumber"`
Salt string `json:"salt"`
Signature string `json:"signature"`
CodeChallenge *CodeChallenge `json:"codeChallenge,omitempty"`
}
Challenge represents an ALTCHA challenge
func CreateChallenge ¶
func CreateChallenge(opts ChallengeOptions) (*Challenge, error)
CreateChallenge generates a new ALTCHA challenge
type ChallengeOptions ¶
type ChallengeOptions struct {
Algorithm string
MaxNumber int
SaltLength int
HMACKey string
Expires time.Time
}
ChallengeOptions contains options for creating a challenge
type CodeChallenge ¶
type CodeChallenge struct {
Image string `json:"image"` // base64-encoded PNG
Length int `json:"length"` // code length
}
CodeChallenge represents an optional visual code challenge
func GenerateCodeChallenge ¶
func GenerateCodeChallenge(length int) (*CodeChallenge, string, error)
GenerateCodeChallenge creates a visual code challenge (image with random code)
type Solution ¶
type Solution struct {
Algorithm string `json:"algorithm"`
Challenge string `json:"challenge"`
Number int `json:"number"`
Salt string `json:"salt"`
Signature string `json:"signature"`
}
Solution represents an ALTCHA solution
func ParsePayload ¶
ParsePayload decodes and parses an ALTCHA payload
Click to show internal directories.
Click to hide internal directories.