Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioc_sixiang_license
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zengtianlai3
ioc_sixiang_license
Commits
2c8a3773
Commit
2c8a3773
authored
Nov 14, 2022
by
AfirSraftGarrier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
格式并加些打印
parent
d7049cf1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
43 deletions
+2
-43
DeviceControllerTest.java
.../iot/sixiang/license/controller/DeviceControllerTest.java
+1
-42
AuthData.java
...c/test/java/iot/sixiang/license/object/data/AuthData.java
+1
-1
No files found.
license/src/test/java/iot/sixiang/license/controller/DeviceControllerTest.java
View file @
2c8a3773
...
@@ -47,7 +47,7 @@ public class DeviceControllerTest {
...
@@ -47,7 +47,7 @@ public class DeviceControllerTest {
String
sign
=
HmacUtil
.
encrypt
(
string
,
appKey
,
HmacUtil
.
HMAC_SHA1
);
String
sign
=
HmacUtil
.
encrypt
(
string
,
appKey
,
HmacUtil
.
HMAC_SHA1
);
// 组装
// 组装
AuthData
authData
=
new
AuthData
();
AuthData
authData
=
new
AuthData
();
authData
.
setApp
I
d
(
appId
);
authData
.
setApp
_i
d
(
appId
);
authData
.
setSn
(
sn
);
authData
.
setSn
(
sn
);
authData
.
setSign
(
sign
);
authData
.
setSign
(
sign
);
byte
[]
dataBytes
=
encryptData_ECB
(
JSON
.
toJSONString
(
authData
),
sm4KeyBytes
);
byte
[]
dataBytes
=
encryptData_ECB
(
JSON
.
toJSONString
(
authData
),
sm4KeyBytes
);
...
@@ -112,47 +112,6 @@ public class DeviceControllerTest {
...
@@ -112,47 +112,6 @@ public class DeviceControllerTest {
@Test
@Test
void
authDevice
()
{
void
authDevice
()
{
byte
[]
stxBytes
=
{(
byte
)
0x55
,
(
byte
)
0xaa
};
// 数据处理过程
// 先随机16组
///**
// * 取随机数生成新key
// */
//for(i=0;i<4;i++)
//{
//*((unsigned int *)(&rand_data[i*4]))=rand()&0xffffffff;
//}
//
//for(i=0;i<16;i++)
//{
// new_key[i]=rand_data[i]^base_key[i];
//}
AuthData
authData
=
new
AuthData
();
authData
.
setAppId
(
"sdfd"
);
authData
.
setSn
(
"sdf"
);
authData
.
setSign
(
"sdf"
);
byte
[]
dataBytes
=
JSON
.
toJSONString
(
authData
).
getBytes
();
int
length
=
dataBytes
.
length
+
stxBytes
.
length
;
byte
[]
lenBytes
=
{(
byte
)
length
,
(
byte
)
(
length
>>
8
)};
byte
cmdByte
=
(
byte
)
0x01
;
byte
ackByte
=
(
byte
)
0x00
;
byte
endByte
=
(
byte
)
0x00
;
// 加密最后字段
endByte
=
(
byte
)
(
endByte
^
cmdByte
);
endByte
=
(
byte
)
(
endByte
^
ackByte
);
for
(
int
i
=
0
;
i
<
length
-
2
;
i
++)
{
endByte
=
(
byte
)
(
endByte
^
dataBytes
[
i
]);
}
byte
[]
allBytes
=
byteMerger
(
stxBytes
,
lenBytes
,
new
byte
[]{
cmdByte
,
ackByte
},
dataBytes
,
new
byte
[]{
endByte
});
System
.
out
.
println
(
bytes2Hex
(
allBytes
));
}
}
public
static
byte
[]
byteMerger
(
byte
[]...
byteList
)
{
public
static
byte
[]
byteMerger
(
byte
[]...
byteList
)
{
...
...
license/src/test/java/iot/sixiang/license/object/data/AuthData.java
View file @
2c8a3773
...
@@ -9,7 +9,7 @@ import lombok.Data;
...
@@ -9,7 +9,7 @@ import lombok.Data;
*/
*/
@Data
@Data
public
class
AuthData
{
public
class
AuthData
{
private
String
app
I
d
;
private
String
app
_i
d
;
private
String
sn
;
private
String
sn
;
private
String
sign
;
private
String
sign
;
}
}
\ No newline at end of file
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