testprint

This commit is contained in:
suyl
2021-07-08 15:52:50 +08:00
parent 986005d40e
commit 94bf08fecc
5 changed files with 81 additions and 1 deletions

View File

@@ -31,7 +31,8 @@ func init() {
}
var (
letterBytes = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
letterBytes = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
letterBytesNum = "0123456789"
)
func RandStringBytes(n int) string {
@@ -42,6 +43,14 @@ func RandStringBytes(n int) string {
return string(b)
}
func RandStringBytesWithNumber(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = letterBytesNum[rand.Intn(len(letterBytesNum))]
}
return string(b)
}
func Captcha(c *gin.Context, length ...int) {
l := captcha.DefaultLen
w, h := 107, 36