代码拉取完成,页面将自动刷新
package captcha
import (
"gitee.com/sansaniot/sansan-core/storage"
"github.com/mojocn/base64Captcha"
)
type cacheStore struct {
cache storage.AdapterCache
expiration int
}
// NewCacheStore returns a new standard memory store for captchas with the
// given collection threshold and expiration time (duration). The returned
// store must be registered with SetCustomStore to replace the default one.
func NewCacheStore(cache storage.AdapterCache, expiration int) base64Captcha.Store {
s := new(cacheStore)
s.cache = cache
s.expiration = expiration
return s
}
// Set sets the digits for the captcha id.
func (e *cacheStore) Set(id string, value string) {
_ = e.cache.Set(id, value, e.expiration)
}
// Get returns stored digits for the captcha id. Clear indicates
// whether the captcha must be deleted from the store.
func (e *cacheStore) Get(id string, clear bool) string {
v, err := e.cache.Get(id)
if err == nil {
if clear {
_ = e.cache.Del(id)
}
return v
}
return ""
}
//Verify captcha's answer directly
func (e *cacheStore) Verify(id, answer string, clear bool) bool {
return e.Get(id, clear) == answer
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。