Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
23584bb7
Commit
23584bb7
authored
Aug 17, 2019
by
Him188moe
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
eca1c1ae
325110e9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
0 deletions
+78
-0
mirai-core/src/test/java/HaxComparator.java
mirai-core/src/test/java/HaxComparator.java
+78
-0
No files found.
mirai-core/src/test/java/HaxComparator.java
0 → 100644
View file @
23584bb7
/**
* @author NaturalHG
* This could be used to check packet encoding..
* but better to run under UNIX
*/
public
class
HaxComparator
{
/**
* a string result
*/
private
static
String
RED
=
"\033[31m"
;
private
static
String
GREEN
=
"\033[33m"
;
public
static
String
compare
(
String
hax1s
,
String
hax2s
){
StringBuilder
builder
=
new
StringBuilder
();
String
[]
hax1
=
hax1s
.
trim
().
split
(
" "
);
String
[]
hax2
=
hax2s
.
trim
().
split
(
" "
);
if
(
hax1
.
length
==
hax2
.
length
){
builder
.
append
(
GREEN
).
append
(
"长度一致:"
).
append
(
hax1
.
length
);
}
else
{
builder
.
append
(
RED
).
append
(
"长度不一致"
).
append
(
hax1
.
length
).
append
(
"/"
).
append
(
hax2
.
length
);
}
StringBuilder
hax1b
=
new
StringBuilder
();
StringBuilder
hax2b
=
new
StringBuilder
();
int
dif
=
0
;
for
(
int
i
=
0
;
i
<
Math
.
max
(
hax1
.
length
,
hax2
.
length
);++
i
){
String
h1
=
null
;
String
h2
=
null
;
boolean
isDif
=
false
;
if
(
hax1
.
length
<=
i
){
h1
=
RED
+
"__"
;
isDif
=
true
;
}
if
(
hax2
.
length
<=
i
){
h2
=
RED
+
"__"
;
isDif
=
true
;
}
if
(
h1
==
null
&&
h2
==
null
){
h1
=
hax1
[
i
];
h2
=
hax2
[
i
];
if
(
h1
.
equals
(
h2
)){
h1
=
GREEN
+
h1
;
h2
=
GREEN
+
h2
;
}
else
{
h1
=
RED
+
h1
;
h2
=
RED
+
h2
;
isDif
=
true
;
}
}
else
{
if
(
h1
==
null
){
h1
=
RED
+
hax1
[
i
];
}
if
(
h2
==
null
){
h2
=
RED
+
hax2
[
i
];
}
}
hax1b
.
append
(
h1
).
append
(
" "
);
hax2b
.
append
(
h2
).
append
(
" "
);
if
(
isDif
){
++
dif
;
}
}
return
(
builder
.
append
(
" "
).
append
(
dif
).
append
(
" 个不同"
).
append
(
"\n"
).
append
(
hax1b
).
append
(
"\n"
).
append
(
hax2b
)).
toString
();
}
public
static
void
main
(
String
[]
args
){
System
.
out
.
println
(
HaxComparator
.
compare
(
"AA CC AA DD EE FF"
,
"AA CC AA DD EE GG HH"
));
}
}
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