Java Code Examples for com.wf.captcha.utils.CaptchaUtil#out()

The following examples show how to use com.wf.captcha.utils.CaptchaUtil#out() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainController.java    From MOOC with MIT License 6 votes vote down vote up
@RequestMapping(value = "changevarcode")//更换验证码,验证码显示
public void changevarcode(HttpServletRequest req,HttpServletResponse res) throws IOException, FontFormatException {

	/*String url=req.getServletContext().getRealPath("/varcodeimg")+"\\"+varcodeurl+".jpg";*/
	
	//验证码生成  varcodenumber为验证码的值
	/* url=req.getServletContext().getRealPath("/varcodeimg")+"\\"+varcodeurl+".jpg";*/
	//写出到response的输出流中
	/*String varcodenumber = NubmerToJpgUtil.NumberToJpgUtil(res.getOutputStream());
	session.setAttribute("varcodenumber",varcodenumber);*/
	//使用新的验证码
	// 设置位数
       //CaptchaUtil.out(5, req, res);
       // 设置宽、高、位数
       //CaptchaUtil.out(130, 48, 5, req, res);
       
       // 使用gif验证码
       GifCaptcha gifCaptcha = new GifCaptcha(130,48,4);
       gifCaptcha.setFont(gifCaptcha.FONT_7);
	CaptchaUtil.out(gifCaptcha,req, res);
}
 
Example 2
Source File: VerifyImageUtil.java    From kk-anti-reptile with Apache License 2.0 5 votes vote down vote up
public VerifyImageDTO generateVerifyImg() {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    String result = CaptchaUtil.out(outputStream);
    String base64Image = "data:image/jpeg;base64," + Base64.getEncoder().encodeToString(outputStream.toByteArray());
    String verifyId = UUID.randomUUID().toString();
    return new VerifyImageDTO(verifyId, null, base64Image, result);
}
 
Example 3
Source File: LoginController.java    From kvf-admin with MIT License 5 votes vote down vote up
/**
 * 图片验证码
 */
@GetMapping(value = "captcha")
public void captcha(HttpServletRequest request, HttpServletResponse response) throws IOException {
    // 可在yml配置kvf.login.authcode.dynamic切换动静态图片验证码,默认静态
    // 其它验证码样式可前往查看:https://gitee.com/whvse/EasyCaptcha
    if (isDynamic) {
        CaptchaUtil.out(new GifCaptcha(), request, response);
    } else {
        CaptchaUtil.out(request, response);
    }
}
 
Example 4
Source File: MainController.java    From easyweb-shiro with MIT License 5 votes vote down vote up
/**
 * 图形验证码,用assets开头可以排除shiro拦截
 */
@RequestMapping("/assets/captcha")
public void captcha(HttpServletRequest request, HttpServletResponse response) {
    try {
        CaptchaUtil.out(request, response);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 5
Source File: SignUpControll.java    From rebuild with GNU General Public License v3.0 4 votes vote down vote up
@RequestMapping("captcha")
public void captcha(HttpServletRequest request, HttpServletResponse response) throws IOException {
	Font font = new Font(Font.SERIF, Font.BOLD & Font.ITALIC, 22 + RandomUtils.nextInt(8));
	int codeLen = 4 + RandomUtils.nextInt(3);
	CaptchaUtil.out(160, 41, codeLen, font, request, response);
}
 
Example 6
Source File: CaptchaServlet.java    From EasyCaptcha with Apache License 2.0 4 votes vote down vote up
public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    CaptchaUtil.out(request, response);
}