首页>代码>Springboot开发的精简博客系统 >/noteblogv4-master/src/main/java/me/wuwenbin/noteblogv4/config/configuration/KaptchaConfig.java
package me.wuwenbin.noteblogv4.config.configuration;

import com.google.code.kaptcha.Constants;
import com.google.code.kaptcha.impl.DefaultKaptcha;
import com.google.code.kaptcha.util.Config;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * 验证码配置
 * created by Wuwenbin on 2018/7/31 at 20:18
 * @author wuwenbin
 */
@Configuration
public class KaptchaConfig {

    @Bean
    @Qualifier("captchaProducer")
    public DefaultKaptcha kaptcha() {
        DefaultKaptcha kaptcha = new DefaultKaptcha();
        Properties properties = new Properties();
        properties.setProperty(Constants.KAPTCHA_BORDER, "yes");
        properties.setProperty(Constants.KAPTCHA_BORDER_COLOR, "220,220,220");
        properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_FONT_COLOR, "38,29,12");
        properties.setProperty(Constants.KAPTCHA_IMAGE_WIDTH, "147");
        properties.setProperty(Constants.KAPTCHA_IMAGE_HEIGHT, "34");
        properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_FONT_SIZE, "25");
        properties.setProperty(Constants.KAPTCHA_SESSION_KEY, "code");
        properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_CHAR_LENGTH, "4");
        properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_FONT_NAMES, "Arial");
        properties.setProperty(Constants.KAPTCHA_NOISE_COLOR, "164,128,55");
        properties.setProperty(Constants.KAPTCHA_OBSCURIFICATOR_IMPL, "com.google.code.kaptcha.impl.ShadowGimpy");
        properties.setProperty(Constants.KAPTCHA_TEXTPRODUCER_CHAR_STRING, "0123456789");
        Config config = new Config(properties);
        kaptcha.setConfig(config);
        return kaptcha;
    }

}
最近下载更多
微信网友_7749187418198016  LV2 2025年10月30日
zolscy  LV24 2024年12月9日
yayacui  LV2 2024年10月28日
angaochong  LV5 2024年10月23日
y1214435276  LV9 2024年9月26日
Peny_ZH  LV5 2024年9月22日
murphy  LV7 2024年7月3日
xunxia  LV7 2024年6月29日
来一杯西瓜冰咩  LV6 2024年5月13日
qiangmin1223  LV12 2024年4月24日
最近浏览更多
denliv_hui  LV14 2025年12月6日
微信网友_7749187418198016  LV2 2025年10月30日
yangctz  LV25 2025年10月29日
orang801  LV2 2025年3月4日
f22m1a2b2  LV17 2025年2月5日
nightstarshii 2025年1月26日
暂无贡献等级
Long1022gnoL 2025年1月17日
暂无贡献等级
莓冰淇淋 2024年12月26日
暂无贡献等级
dengge123  LV14 2024年12月13日
haomc052829  LV4 2024年12月3日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友