mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-02 11:20:18 +08:00
Add github.com/dchest/captcha imports.
This commit is contained in:
26
object/captcha.go
Normal file
26
object/captcha.go
Normal file
@ -0,0 +1,26 @@
|
||||
package object
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/dchest/captcha"
|
||||
)
|
||||
|
||||
func GetCaptcha() (string, []byte) {
|
||||
id := captcha.NewLen(5)
|
||||
|
||||
var buffer bytes.Buffer
|
||||
|
||||
err := captcha.WriteImage(&buffer, id, 200, 80)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return id, buffer.Bytes()
|
||||
}
|
||||
|
||||
func VerifyCaptcha(id string, digits string) bool {
|
||||
res := captcha.VerifyString(id, digits)
|
||||
|
||||
return res
|
||||
}
|
Reference in New Issue
Block a user