# captchaStore **Repository Path**: aesoper/captchaStore ## Basic Information - **Project Name**: captchaStore - **Description**: 基于base64Captcha开发的验证码存储驱动,由于base64Captcha类库生成的验证码只支持内存存储,故而当你在分布式环境中使用该类库时就会出现问题,造成正确的验证验证不通过的情况,因此开发了captchaStore的存储驱动 - **Primary Language**: Go - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 0 - **Created**: 2020-05-19 - **Last Updated**: 2021-09-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # captchaStore #### 介绍 基于base64Captcha开发的验证码存储驱动,由于base64Captcha类库生成的验证码只支持内存存储,故而当你在分布式环境中使用该类库时就会出现问题,造成正确的验证验证不通过的情况,因此开发了captchaStore的存储驱动 #### 软件架构 该仓库是基于[base64Captcha](https://github.com/mojocn/base64Captcha) 以及 [cache](https://gitee.com/aesoper/cache) 的store 存储接口开发的验证码永久存储驱动,目前支持redis以及memcache的存储方案, 如果这还不能满足您的需要,您还可以扩展 #### 安装教程 1. ```go get -u gitee.com/aesoper/captchaStore``` #### 使用说明 话不多说直接贴测试代码 ```go import ( "gitee.com/aesoper/cache" "gitee.com/aesoper/cache/redis" "github.com/mojocn/base64Captcha" "testing" "time" ) func TestCustomCaptchaStore(t *testing.T) { driver := &base64Captcha.DriverDigit{ Height: 40, Width: 150, Length: 4, MaxSkew: 1, DotCount: 1, } c, err := cache.New(cache.Cfg{ Driver: "redis", Redis: redis.Options{ Addr: "localhost:6379", }, }) if err != nil { t.Errorf("init cache failed: %s", err) } store := NewCustomCaptchaStore(c, time.Minute * 5, false) captcha := base64Captcha.NewCaptcha(driver, store) // 生成验证码base64字符串 _, _, err = captcha.Generate() if err != nil { t.Errorf("generate captcha failed: %s", err) } } ``` #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 感谢 1. [base64Captcha](https://github.com/mojocn/base64Captcha) 2. [cache](https://gitee.com/aesoper/cache) #### 码云特技 1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md 2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com) 3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目 4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目 5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) 6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)