| New file | 
|  |  |  | 
|---|
|  |  |  | 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 KaptchaMathOneTextCreator extends DefaultTextCreator { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public String getText() { | 
|---|
|  |  |  | Random random = new SecureRandom(); | 
|---|
|  |  |  | // 生成两个随机数,随机数范围:[0,10),并返回结果 | 
|---|
|  |  |  | Map<String, String> result = CaptchaUtil.mathTextCreator(random.nextInt(10), random.nextInt(10)); | 
|---|
|  |  |  | return result.get("resultString"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|