Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
ReyunSecureSdk
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhanglei
ReyunSecureSdk
Commits
aff26ecf
Commit
aff26ecf
authored
Mar 31, 2021
by
1256748979@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
b1e36fde
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
4 deletions
+107
-4
MyApplication.java
app/src/main/java/com/reyun/sdktestdemo/MyApplication.java
+33
-0
Md5Utils.java
wandun/src/main/java/com/reyun/wandun/Md5Utils.java
+48
-0
WdCallback.java
wandun/src/main/java/com/reyun/wandun/WdCallback.java
+2
-1
WdMain.java
wandun/src/main/java/com/reyun/wandun/WdMain.java
+24
-3
No files found.
app/src/main/java/com/reyun/sdktestdemo/MyApplication.java
0 → 100644
View file @
aff26ecf
package
com
.
reyun
.
sdktestdemo
;
import
android.app.Application
;
import
android.util.Log
;
import
com.reyun.wandun.WdCallback
;
import
com.reyun.wandun.WdMain
;
public
class
MyApplication
extends
Application
{
public
static
String
TAG
=
"reyunsdk_demo"
;
@Override
public
void
onCreate
()
{
super
.
onCreate
();
//初始化sdk环境
WdMain
wm
=
WdMain
.
getInstance
();
wm
.
init
(
this
,
"test-a341fsfr3123ddadfs"
);
//同步获取唯一id
wm
.
getWdId
(
new
WdCallback
()
{
@Override
public
void
onWdId
(
String
wdId
)
{
Log
.
d
(
TAG
,
"onWdId: "
+
wdId
);
}
/*
@Override
public void onError(String errorMsg) {
Log.d(TAG, "onError: " + errorMsg);
}*/
});
}
}
wandun/src/main/java/com/reyun/wandun/Md5Utils.java
0 → 100644
View file @
aff26ecf
package
com
.
reyun
.
wandun
;
import
android.os.Message
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
public
class
MdUtils
{
public
static
String
md5
(
String
data
)
{
try
{
MessageDigest
md
=
MessageDigest
.
getInstance
(
"md5"
);
byte
[]
result
=
md
.
digest
(
data
.
getBytes
());
return
bytes2HexString
(
result
);
}
catch
(
NoSuchAlgorithmException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
private
static
byte
charToByte
(
char
c
)
{
return
(
byte
)
"0123456789abcdef"
.
indexOf
(
c
);
}
public
static
byte
[]
hexString2Bytes
(
String
hex
)
{
int
len
=
(
hex
.
length
()
/
2
);
byte
[]
result
=
new
byte
[
len
];
char
[]
achar
=
hex
.
toCharArray
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
int
pos
=
i
*
2
;
result
[
i
]
=
(
byte
)
(
charToByte
(
achar
[
pos
])
<<
4
|
charToByte
(
achar
[
pos
+
1
]));
}
return
result
;
}
public
static
String
bytes2HexString
(
byte
[]
byteArray
)
{
if
(
byteArray
==
null
)
{
return
null
;
}
char
[]
hexArray
=
"0123456789ABCDEF"
.
toCharArray
();
char
[]
hexChars
=
new
char
[
byteArray
.
length
*
2
];
for
(
int
j
=
0
;
j
<
byteArray
.
length
;
j
++)
{
int
v
=
byteArray
[
j
]
&
0xFF
;
hexChars
[
j
*
2
]
=
hexArray
[
v
>>>
4
];
hexChars
[
j
*
2
+
1
]
=
hexArray
[
v
&
0x0F
];
}
return
new
String
(
hexChars
);
}
}
wandun/src/main/java/com/reyun/wandun/WdCallback.java
View file @
aff26ecf
package
com
.
reyun
.
wandun
;
package
com
.
reyun
.
wandun
;
public
interface
WdCallback
{
public
interface
WdCallback
{
String
onWdId
(
String
wdId
);
void
onWdId
(
String
wdId
);
// void onError(String errorMsg);
}
}
wandun/src/main/java/com/reyun/wandun/WdMain.java
View file @
aff26ecf
package
com
.
reyun
.
wandun
;
package
com
.
reyun
.
wandun
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.SharedPreferences
;
public
class
WdMain
{
public
class
WdMain
{
private
static
WdMain
mInstance
=
new
WdMain
();
// 用户申请sdk后获得的认证码,调用sdk接口时需传入
// 用户申请sdk后获得的认证码,调用sdk接口时需传入
private
String
mApiKey
;
private
String
mApiKey
;
...
@@ -12,8 +15,15 @@ public class WdMain {
...
@@ -12,8 +15,15 @@ public class WdMain {
//app context
//app context
private
Context
mContext
;
private
Context
mContext
;
public
static
WdMain
getInstance
(){
return
mInstance
;
}
//初始化方法,
//初始化方法,
public
static
void
init
(
Context
context
,
String
apiKey
)
{
public
void
init
(
Context
context
,
String
apiKey
)
{
mContext
=
context
;
mApiKey
=
apiKey
;
//load native lib
//load native lib
System
.
loadLibrary
(
"wdun"
);
System
.
loadLibrary
(
"wdun"
);
...
@@ -22,7 +32,18 @@ public class WdMain {
...
@@ -22,7 +32,18 @@ public class WdMain {
}
}
//获取wdId
//获取wdId
public
static
void
getWdId
(
WdCallback
cb
)
{
public
void
getWdId
(
WdCallback
cb
)
{
String
wdId
;
//文件中读取
SharedPreferences
sp
=
mContext
.
getSharedPreferences
(
"wd_dna"
,
Context
.
MODE_PRIVATE
);
wdId
=
sp
.
getString
(
MdUtils
.
md5
(
"device_id"
),
null
);
if
(
wdId
==
null
)
{
//重新请求服务器获取
wdId
=
getWdIdNative
();
}
cb
.
onWdId
(
wdId
);
}
}
//native层获取wdId
public
native
String
getWdIdNative
();
}
}
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