Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
d8313c69
Commit
d8313c69
authored
Jan 10, 2022
by
hweeeeeei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化AppSecret生成规则: 不使用key作为加密字符串,防止被破解
parent
4233f56a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
10 deletions
+13
-10
bootstrap/src/test/java/io/geekidea/springbootplus/test/ImApplicationTest.java
+4
-4
core/src/main/java/com/wecloud/im/ws/utils/KeyGenerator.java
+9
-6
No files found.
bootstrap/src/test/java/io/geekidea/springbootplus/test/ImApplicationTest.java
View file @
d8313c69
...
...
@@ -27,8 +27,8 @@ public class ImApplicationTest {
private
ImApplicationService
imApplicationService
;
public
static
void
main
(
String
[]
args
)
{
String
appKey
=
KeyGenerator
.
get
AppKey
();
//定义变量接收
String
appSecret
=
KeyGenerator
.
getAppSecret
(
appKey
);
String
appKey
=
KeyGenerator
.
get
RandomString
();
//定义变量接收
String
appSecret
=
KeyGenerator
.
getAppSecret
();
int
i
=
1
;
}
...
...
@@ -42,10 +42,10 @@ public class ImApplicationTest {
private
void
addDb
(
int
i
)
{
// 生成AppKey
String
appKey
=
KeyGenerator
.
get
AppKey
();
//定义变量接收
String
appKey
=
KeyGenerator
.
get
RandomString
();
//定义变量接收
// 生成appSecret
String
appSecret
=
KeyGenerator
.
getAppSecret
(
appKey
);
String
appSecret
=
KeyGenerator
.
getAppSecret
();
ImApplication
imApplication
=
new
ImApplication
();
imApplication
.
setCreateTime
(
new
Date
());
...
...
core/src/main/java/com/wecloud/im/ws/utils/KeyGenerator.java
View file @
d8313c69
...
...
@@ -12,8 +12,10 @@ public class KeyGenerator {
"J"
,
"K"
,
"L"
,
"M"
,
"N"
,
"O"
,
"P"
,
"Q"
,
"R"
,
"S"
,
"T"
,
"U"
,
"V"
,
"W"
,
"X"
,
"Y"
,
"Z"
};
//生成8位appKey
public
static
String
getAppKey
()
{
/*
* 生成随机字符串
*/
public
static
String
getRandomString
()
{
StringBuffer
shortBuffer
=
new
StringBuffer
();
//获取用户id进行字符串截取
String
uuid
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
...
...
@@ -25,15 +27,16 @@ public class KeyGenerator {
return
shortBuffer
.
toString
();
// return UUID.randomUUID().toString().replace("-", "");
}
//生成32位appSecret
public
static
String
getAppSecret
(
String
appId
)
{
/*
*生成32位appSecret
*/
public
static
String
getAppSecret
()
{
String
encryoAppSecret
=
""
;
try
{
EncrypDES
des1
=
new
EncrypDES
();
// 使用默认密钥
encryoAppSecret
=
des1
.
encrypt
(
appId
);
encryoAppSecret
=
des1
.
encrypt
(
KeyGenerator
.
getRandomString
()
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
...
...
Write
Preview
Markdown
is supported
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