zhubaomin
2024-09-24 955ec151b467016c24235e28b9ea09d324db7139
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.dy.pipIrrApp.config;
 
import com.dy.pipIrrApp.util.CaptchaUtil;
import com.google.code.kaptcha.text.impl.DefaultTextCreator;
 
import java.security.SecureRandom;
import java.util.Map;
import java.util.Random;
 
/**
 * @author ZhuBaoMin
 * @date 2024-09-11 15:51
 * @LastEditTime 2024-09-11 15:51
 * @Description
 */
 
public class KaptchaMathTwoTextCreator extends DefaultTextCreator {
    @Override
    public String getText() {
        Random random = new SecureRandom();
        // 保存计算结果
        Map<String, String> result = CaptchaUtil.mathTextCreator(random.nextInt(100), random.nextInt(100));
        // 生成两个随机数,随机数范围:[0,100),并返回结果
        return result.get("resultString");
    }
}