Golang 中如何优雅的生成验证码:
Golang 中如何优雅的生成验证码: package main import ( // "os" "github.com/mojocn/base64Captcha" ) func main() { var configC = base64Captcha.ConfigCharacter{ Height: 88, Width:240, // const CaptchaModeNumber:数字,CaptchaModeAlphabet:字母,CaptchaModeArithmetic:算术,CaptchaModeNumberAlphabet:数字字母混合. Mode: base64Captcha.CaptchaModeArithmetic, ComplexOfNoiseText: base64Captcha.CaptchaComplexMedium, ComplexOfNoiseDot:base64Captcha.CaptchaComplexMedium, IsUseSimpleFont:true, IsShowHollowLine: true, IsShowNoiseDot: true, IsShowNoiseText:false, IsShowSlimeLine:true, IsShowSineLine: true, CaptchaLen: 6, } // GenerateCaptcha 第一个参数为空字符串, 包会自动在服务器一个随机种子给你产生随机uiid. idKeyC, capC := base64Captcha.GenerateCaptcha("", configC) // 以base64编码保存为文件 base64Captcha.CaptchaWriteToFile(capC, "./", idKeyC, "png") // 获取正确答案 verifyValue := capC.(*base64Captcha.CaptchaImageChar).VerifyValue // 展示正确答案 // println(verifyValue) // 删除内存键防止内存泄漏 base64Captcha.VerifyCaptchaAndIsClear(idKeyC, verifyValue, true) // os.Remove("./" + idKeyC + "png") } 全文: https://gtary.com/2020/05/14/2970.html
在Telegram中查看相关推荐

🔍 发送关键词来寻找群组、频道或视频。
启动SOSO机器人