Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
4e58afd5
"JeeSpringCloud/src/vscode:/vscode.git/clone" did not exist on "d5ba54ba7b33fe06ed051979beaeede34c9c2cf8"
Commit
4e58afd5
authored
Mar 05, 2021
by
Zheng Jie
Browse files
Merge branch 'master' of
https://github.com/elunez/eladmin
parents
cd85594e
a49bd6d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/security/config/bean/LoginProperties.java
View file @
4e58afd5
...
@@ -80,7 +80,7 @@ public class LoginProperties {
...
@@ -80,7 +80,7 @@ public class LoginProperties {
switch
(
loginCode
.
getCodeType
())
{
switch
(
loginCode
.
getCodeType
())
{
case
arithmetic:
case
arithmetic:
// 算术类型 https://gitee.com/whvse/EasyCaptcha
// 算术类型 https://gitee.com/whvse/EasyCaptcha
captcha
=
new
ArithmeticCaptcha
(
loginCode
.
getWidth
(),
loginCode
.
getHeight
());
captcha
=
new
Fixed
ArithmeticCaptcha
(
loginCode
.
getWidth
(),
loginCode
.
getHeight
());
// 几位数运算,默认是两位
// 几位数运算,默认是两位
captcha
.
setLen
(
loginCode
.
getLength
());
captcha
.
setLen
(
loginCode
.
getLength
());
break
;
break
;
...
@@ -109,4 +109,27 @@ public class LoginProperties {
...
@@ -109,4 +109,27 @@ public class LoginProperties {
}
}
return
captcha
;
return
captcha
;
}
}
static
class
FixedArithmeticCaptcha
extends
ArithmeticCaptcha
{
public
FixedArithmeticCaptcha
(
int
width
,
int
height
)
{
super
(
width
,
height
);
}
@Override
protected
char
[]
alphas
()
{
// 生成随机数字和运算符
int
n1
=
num
(
1
,
10
),
n2
=
num
(
1
,
10
);
int
opt
=
num
(
3
);
// 计算结果
int
res
=
new
int
[]{
n1
+
n2
,
n1
-
n2
,
n1
*
n2
}[
opt
];
// 转换为字符运算符
char
optChar
=
"+-x"
.
charAt
(
opt
);
this
.
setArithmeticString
(
String
.
format
(
"%s%c%s=?"
,
n1
,
optChar
,
n2
));
this
.
chars
=
String
.
valueOf
(
res
);
return
chars
.
toCharArray
();
}
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment