|
|
|
@ -17,9 +17,14 @@ var DefaultConfig = base64Captcha.DriverString{ |
|
|
|
|
Source: "1234567890qwertyuioplkjhgfdsazxcvbnm", |
|
|
|
|
Fonts: []string{"wqy-microhei.ttc", "chromohv.ttf", "actionj.ttf", "RitaSmith.ttf"}, |
|
|
|
|
} |
|
|
|
|
var DefaultStore = base64Captcha.DefaultMemStore |
|
|
|
|
|
|
|
|
|
func Generate(store base64Captcha.Store) (id, b64s string, err error) { |
|
|
|
|
return base64Captcha.NewCaptcha(&DefaultConfig, store).Generate() |
|
|
|
|
func SetStore(store base64Captcha.Store) { |
|
|
|
|
DefaultStore = store |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func Generate() (id, b64s string, err error) { |
|
|
|
|
return base64Captcha.NewCaptcha(&DefaultConfig, DefaultStore).Generate() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type redisStore struct { |
|
|
|
@ -33,7 +38,7 @@ func NewRedisStore(redis *redis.Client) *redisStore { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (r *redisStore) Key(key string) string { |
|
|
|
|
return fmt.Sprintf("captach::%s", key) |
|
|
|
|
return fmt.Sprintf("captach:%s", key) |
|
|
|
|
} |
|
|
|
|
func (r *redisStore) Set(id string, value string) error { |
|
|
|
|
return r.redis.Set(r.Key(id), value, time.Second*3700).Err() |
|
|
|
|