Ai-interviewer-system/src/main/java/com/yzdx/AiInterviewer/utiles/RandomCodeUtil.java

22 lines
566 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.yzdx.AiInterviewer.utiles;
import java.util.Random;
public class RandomCodeUtil {
/**
* 生成的验证码
* @param index 生成验证码的长度
* @return
*/
public static String random(Integer index){
String code = "";
Random rd=new Random();
for (int i = 0; i < index; i++) {
int r = rd.nextInt(10); //每次随机出一个数字0-9
code = code + r; //把每次随机出的数字拼在一起
}
System.out.println(code);
return code;
}
}