use of cn.hutool.captcha.CircleCaptcha in project Jpom by dromara.
the class LoginControl method randCode.
/**
* 验证码
*
* @throws IOException IO
*/
@RequestMapping(value = "randCode.png", method = RequestMethod.GET, produces = MediaType.IMAGE_PNG_VALUE)
@NotLogin
public void randCode() throws IOException {
int height = 50;
CircleCaptcha circleCaptcha = new CircleCaptcha(100, height, 4, 8);
// 设置为默认字体
circleCaptcha.setFont(new Font(null, Font.PLAIN, (int) (height * 0.75)));
circleCaptcha.createCode();
HttpServletResponse response = getResponse();
circleCaptcha.write(response.getOutputStream());
String code = circleCaptcha.getCode();
setSessionAttribute(LOGIN_CODE, code);
}
use of cn.hutool.captcha.CircleCaptcha in project RuoYi-Flowable-Plus by KonBAI-Q.
the class CaptchaConfig method circleCaptcha.
/**
* 圆圈干扰验证码
*/
@Lazy
@Bean
public CircleCaptcha circleCaptcha() {
CircleCaptcha captcha = CaptchaUtil.createCircleCaptcha(width, height);
captcha.setBackground(background);
captcha.setFont(font);
return captcha;
}
use of cn.hutool.captcha.CircleCaptcha in project ruoyi-vue-pro by YunaiV.
the class CaptchaServiceImpl method getCaptchaImage.
@Override
public CaptchaImageRespVO getCaptchaImage() {
if (!Boolean.TRUE.equals(enable)) {
return CaptchaImageRespVO.builder().enable(enable).build();
}
// 生成验证码
CircleCaptcha captcha = CaptchaUtil.createCircleCaptcha(captchaProperties.getWidth(), captchaProperties.getHeight());
// 缓存到 Redis 中
String uuid = IdUtil.fastSimpleUUID();
captchaRedisDAO.set(uuid, captcha.getCode(), captchaProperties.getTimeout());
// 返回
return CaptchaConvert.INSTANCE.convert(uuid, captcha).setEnable(enable);
}
use of cn.hutool.captcha.CircleCaptcha in project RuoYi-Vue-Plus by JavaLionLi.
the class CaptchaConfig method circleCaptcha.
/**
* 圆圈干扰验证码
*/
@Lazy
@Bean
public CircleCaptcha circleCaptcha() {
CircleCaptcha captcha = CaptchaUtil.createCircleCaptcha(width, height);
captcha.setBackground(background);
captcha.setFont(font);
return captcha;
}
Aggregations