// GenerateCaptcha return captcha number and base64 encoded image
GenerateCaptcha return captcha number and base64 encoded image
// GenerateCaptcha return captcha number and base64 encoded image
func GenerateCaptcha(item *StorageItem) string {
	cap := captcha.New()
	cap.SetSize(512, 128)
	cap.AddFontFromBytes(GetRandomCaptchaFont(item.Language))
	cap.SetFrontColor(color.RGBA{uint8(GetRandomNumber(0, 64)), uint8(GetRandomNumber(0, 64)), uint8(GetRandomNumber(0, 64)), 0xff})
	cap.SetBkgColor(color.RGBA{uint8(GetRandomNumber(192, 256)), uint8(GetRandomNumber(192, 256)), uint8(GetRandomNumber(192, 256)), 0xff})
	if item.Level == LevelEasy {
		cap.SetDisturbance(32)
	} else if item.Level == LevelHard {
		cap.SetDisturbance(192)
	} else {
		cap.SetDisturbance(64)
	}
	img := cap.CreateCustom(item.IntlValue)
	buf := new(bytes.Buffer)
	jpeg.Encode(buf, img, &jpeg.Options{
		Quality: 33,
	})
	return "data:image/jpeg;base64," + base64.StdEncoding.EncodeToString(buf.Bytes())
}
func GenerateCaptcha ( item * StorageItem ) string { cap := captcha . New ( ) cap . SetSize ( 512 , 128 ) cap . AddFontFromBytes ( GetRandomCaptchaFont ( item . Language ) ) cap . SetFrontColor ( color . RGBA { uint8 ( GetRandomNumber ( 0 , 64 ) ) , uint8 ( GetRandomNumber ( 0 , 64 ) ) , uint8 ( GetRandomNumber ( 0 , 64 ) ) , 0xff } ) cap . SetBkgColor ( color . RGBA { uint8 ( GetRandomNumber ( 192 , 256 ) ) , uint8 ( GetRandomNumber ( 192 , 256 ) ) , uint8 ( GetRandomNumber ( 192 , 256 ) ) , 0xff } ) if item . Level == LevelEasy { cap . SetDisturbance ( 32 ) } else if item . Level == LevelHard { cap . SetDisturbance ( 192 ) } else { cap . SetDisturbance ( 64 ) } img := cap . CreateCustom ( item . IntlValue ) buf := new ( bytes . Buffer ) jpeg . Encode ( buf , img , & jpeg . Options { Quality : 33 , } ) return " " + base64 . StdEncoding . EncodeToString ( buf . Bytes ( ) ) }
GenerateCaptcha return captcha number and base64 encoded image
GenerateCaptcha return captcha number and base64 encoded image