public class RandomGenerator extends AbstractGenerator
baseStr, length
Constructor and Description |
---|
RandomGenerator(int count)
构造,使用字母+数字做为基础
|
RandomGenerator(String baseStr,
int length)
构造
|
Modifier and Type | Method and Description |
---|---|
String |
generate()
生成验证码
|
boolean |
verify(String code,
String userInputCode)
验证用户输入的字符串是否与生成的验证码匹配
用户通过实现此方法定义验证码匹配方式 |
getLength
public RandomGenerator(int count)
count
- 生成验证码长度public RandomGenerator(String baseStr, int length)
baseStr
- 基础字符集合,用于随机获取字符串的字符集合length
- 生成验证码长度public String generate()
CodeGenerator
public boolean verify(String code, String userInputCode)
CodeGenerator
code
- 生成的随机验证码userInputCode
- 用户输入的验证码Copyright © 2024. All rights reserved.