Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_street
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
android
android_street
Commits
dc4c934e
Commit
dc4c934e
authored
Jul 01, 2021
by
fengruiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
项目正常跑起来
parent
7c16a2b2
Changes
21
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
379 additions
and
541 deletions
+379
-541
compiler.xml
.idea/compiler.xml
+1
-1
misc.xml
.idea/misc.xml
+4
-1
runConfigurations.xml
.idea/runConfigurations.xml
+1
-0
build.gradle
app/build.gradle
+44
-21
configProduct.properties
app/configs/auto/configProduct.properties
+0
-4
configTest.properties
app/configs/auto/configTest.properties
+0
-4
supplierconfig.json
app/configs/auto/supplierconfig.json
+0
-17
config.properties
app/configs/release/config.properties
+0
-4
supplierconfig.json
app/configs/release/supplierconfig.json
+0
-17
library.build.gradle
library.build.gradle
+16
-13
build.gradle
library_base/build.gradle
+7
-7
BaseModuleInit.java
..._base/src/main/java/com/fry/base/base/BaseModuleInit.java
+10
-13
Constants.java
...ary_base/src/main/java/com/fry/base/global/Constants.java
+4
-4
InitConstants.java
...base/src/main/java/com/fry/base/global/InitConstants.java
+4
-1
OkHttpInterceptor.kt
...e/src/main/java/com/fry/base/netwrok/OkHttpInterceptor.kt
+200
-199
BuildConfigUtils.java
...se/src/main/java/com/fry/base/utils/BuildConfigUtils.java
+0
-50
PropertyKey.java
...ry_base/src/main/java/com/fry/base/utils/PropertyKey.java
+0
-19
PropertyUtils.java
..._base/src/main/java/com/fry/base/utils/PropertyUtils.java
+0
-82
AESUtils.java
...base/src/main/java/com/fry/base/utils/encry/AESUtils.java
+83
-81
version.properties
library_base/version.properties
+2
-2
build.gradle
mvvmhabit/build.gradle
+3
-1
No files found.
.idea/compiler.xml
View file @
dc4c934e
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"CompilerConfiguration"
>
<bytecodeTargetLevel
target=
"1
.8
"
/>
<bytecodeTargetLevel
target=
"1
1
"
/>
</component>
</project>
\ No newline at end of file
.idea/misc.xml
View file @
dc4c934e
...
...
@@ -5,10 +5,13 @@
<configuration
PROFILE_NAME=
"Debug"
CONFIG_NAME=
"Debug"
/>
</configurations>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1
_8
"
default=
"true"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1
1
"
default=
"true"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/build/classes"
/>
</component>
<component
name=
"ProjectType"
>
<option
name=
"id"
value=
"Android"
/>
</component>
<component
name=
"SuppressKotlinCodeStyleNotification"
>
<option
name=
"disableForAll"
value=
"true"
/>
</component>
</project>
\ No newline at end of file
.idea/runConfigurations.xml
View file @
dc4c934e
...
...
@@ -3,6 +3,7 @@
<component
name=
"RunConfigurationProducerService"
>
<option
name=
"ignoredProducers"
>
<set>
<option
value=
"com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer"
/>
<option
value=
"org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer"
/>
<option
value=
"org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer"
/>
<option
value=
"org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer"
/>
...
...
app/build.gradle
View file @
dc4c934e
...
...
@@ -10,6 +10,10 @@ android {
targetSdkVersion
rootProject
.
ext
.
android
.
targetSdkVersion
versionCode
rootProject
.
ext
.
android
.
versionCode
versionName
rootProject
.
ext
.
android
.
versionName
//flavorDimensions "default"
buildConfigField
(
"boolean"
,
"IS_DEV"
,
"false"
)
}
dataBinding
{
...
...
@@ -19,31 +23,50 @@ android {
sourceCompatibility
rootProject
.
ext
.
java_version
[
"compileJavaVersion"
]
targetCompatibility
rootProject
.
ext
.
java_version
[
"targetJavaVersion"
]
}
productFlavors
{
// 开发版本
auto
{
buildConfigField
(
'boolean'
,
'IS_DEV'
,
"true"
)
manifestPlaceholders
=
[
app_logo_name:
"Auto"
]
}
// 线上产品版本
product
{
buildConfigField
(
'boolean'
,
'IS_DEV'
,
"false"
)
manifestPlaceholders
=
[
app_logo_name:
"线上"
]
}
}
// buildTypes {
// debug {
// minifyEnabled false
// //signingConfig signingConfigs.release
// zipAlignEnabled true
// versionNameSuffix "-dev"
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// }
// release {
// minifyEnabled false
// zipAlignEnabled true
// shrinkResources false
// //signingConfig signingConfigs.release
// proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// }
// }
// productFlavors {
// // 开发版本
// auto {
// buildConfigField ('boolean','IS_DEV',"true")
// manifestPlaceholders = [
// app_logo_name: "Auto"
// ]
// }
// // 线上产品版本
// product {
// buildConfigField ('boolean','IS_DEV',"false")
// manifestPlaceholders = [
// app_logo_name: "线上"
// ]
// }
// }
}
dependencies
{
implementation
fileTree
(
dir:
"libs"
,
include:
[
"*.jar"
])
implementation
'androidx.appcompat:appcompat:1.1.0'
implementation
'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation
'junit:junit:4.12'
androidTestImplementation
'androidx.test.ext:junit:1.1.1'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.2.0'
testImplementation
rootProject
.
ext
.
support
[
"junit"
]
// implementation 'androidx.appcompat:appcompat:1.1.0'
// implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
// testImplementation 'junit:junit:4.12'
// androidTestImplementation 'androidx.test.ext:junit:1.1.1'
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
api
project
(
':library_base'
)
...
...
app/configs/auto/configProduct.properties
deleted
100644 → 0
View file @
7c16a2b2
# 环境名
name
=
product
api.base.url
=
https://
isProduct
=
true
\ No newline at end of file
app/configs/auto/configTest.properties
deleted
100644 → 0
View file @
7c16a2b2
# 环境名 默认
name
=
test
api.base.url
=
http://apitest.
isProduct
=
false
\ No newline at end of file
app/configs/auto/supplierconfig.json
deleted
100644 → 0
View file @
7c16a2b2
{
"supplier"
:{
"vivo"
:{
"appid"
:
"103881568"
},
"xiaomi"
:{
"appid"
:
"2882303761518348857"
},
"huawei"
:{
"appid"
:
"101833995"
},
"oppo"
:{
"appid"
:
"30251013"
}
}
}
app/configs/release/config.properties
deleted
100644 → 0
View file @
7c16a2b2
# 环境名
name
=
product
api.base.url
=
https://api.
isProduct
=
true
\ No newline at end of file
app/configs/release/supplierconfig.json
deleted
100644 → 0
View file @
7c16a2b2
{
"supplier"
:{
"vivo"
:{
"appid"
:
"103881568"
},
"xiaomi"
:{
"appid"
:
"2882303761518348857"
},
"huawei"
:{
"appid"
:
"101833995"
},
"oppo"
:{
"appid"
:
"30251013"
}
}
}
library.build.gradle
View file @
dc4c934e
...
...
@@ -15,8 +15,11 @@ android {
versionName
rootProject
.
ext
.
android
.
versionName
flavorDimensions
'23'
multiDexEnabled
true
buildConfigField
(
"boolean"
,
"IS_DEV"
,
"false"
)
buildConfigField
(
"String"
,
"AppKeyPre"
,
"abcd"
)
buildConfigField
(
"boolean"
,
"IS_DEV"
,
"false"
)
//从com.android.tools.build:gradle:4.1.0开始,build.gradle文件正式移除了versionName和versionCode,参照Android开发者官网。
buildConfigField
(
"String"
,
"VERSION_NAME"
,
"\""
+
rootProject
.
ext
.
android
.
versionName
+
"\""
)
buildConfigField
(
"String"
,
"VERSION_CODE"
,
"\""
+
rootProject
.
ext
.
android
.
versionCode
+
"\""
)
buildConfigField
(
"String"
,
"AppKeyPre"
,
"\""
+
"abcd"
+
"\""
)
}
...
...
@@ -52,17 +55,17 @@ android {
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
}
}
productFlavors
{
//包含所有环境
auto
{
buildConfigField
(
"boolean"
,
"IS_DEV"
,
"true"
)
}
// 线上产品版本
product
{
buildConfigField
(
"boolean"
,
"IS_DEV"
,
"false"
)
}
}
//
productFlavors {
//
//包含所有环境
//
auto {
//
buildConfigField ("boolean","IS_DEV","true")
//
}
//
// 线上产品版本
//
product {
//
buildConfigField ("boolean","IS_DEV","false")
//
}
//
}
//
compileOptions
{
sourceCompatibility
rootProject
.
ext
.
java_version
[
"compileJavaVersion"
]
...
...
library_base/build.gradle
View file @
dc4c934e
...
...
@@ -23,13 +23,13 @@ android {
buildConfigField
(
"int"
,
"BUILD_VERSION"
,
"${buildVersion}"
)
}
//
noArg {
//
annotation("com.jeme.base.annotation.Poko")
//
}
//
//
allOpen {
//
annotation("com.jeme.base.annotation.Poko")
//
}
noArg
{
annotation
(
"com.jeme.base.annotation.Poko"
)
}
allOpen
{
annotation
(
"com.jeme.base.annotation.Poko"
)
}
}
dependencies
{
implementation
fileTree
(
include:
[
'*.jar'
,
'*.aar'
],
dir:
'libs'
)
...
...
library_base/src/main/java/com/fry/base/base/BaseModuleInit.java
View file @
dc4c934e
...
...
@@ -4,9 +4,7 @@ import android.app.Application;
import
android.view.Gravity
;
import
com.alibaba.android.arouter.launcher.ARouter
;
import
com.fry.base.BuildConfig
;
import
com.fry.base.global.Constants
;
import
com.fry.base.utils.PropertyUtils
;
import
com.tencent.bugly.crashreport.CrashReport
;
import
me.goldze.mvvmhabit.utils.KLog
;
...
...
@@ -21,15 +19,14 @@ import me.goldze.mvvmhabit.utils.ToastUtils;
public
class
BaseModuleInit
implements
IModuleInit
<
Void
>
{
@Override
public
boolean
onInitAhead
(
Application
application
,
boolean
isMainProcess
)
{
// 环境配置读取初始化优先级最高,要先初始化
PropertyUtils
.
init
(
application
);
//开启打印日志
KLog
.
init
(
BuildConfig
.
DEBUG
);
//初始化阿里路由框架
if
(
BuildConfig
.
DEBUG
)
{
ARouter
.
openLog
();
// 打印日志
ARouter
.
openDebug
();
// 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
}
//
KLog.init(BuildConfig.DEBUG);
//
//初始化阿里路由框架
//
if (BuildConfig.DEBUG) {
//
ARouter.openLog(); // 打印日志
//
ARouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
//
}
// 尽可能早,推荐在Application中初始化
ARouter
.
init
(
application
);
ToastUtils
.
setGravity
(
Gravity
.
CENTER
,
0
,
0
);
...
...
@@ -42,9 +39,9 @@ public class BaseModuleInit implements IModuleInit<Void> {
// 这里实现SDK初始化,appId替换成你的在Bugly平台申请的appId
// 调试时,将第三个参数改为true
// Bugly.init(application, Constants.BUGLY_APP_ID, BuildConfig.IS_DEV);
if
(!
BuildConfig
.
IS_DEV
&&
!
SPUtils2
.
getInstance
().
decodeBoolean
(
"isFirstOpen"
,
true
)){
CrashReport
.
initCrashReport
(
application
,
Constants
.
BUGLY_APP_ID
,
false
);
}
//
if(!BuildConfig.IS_DEV && ! SPUtils2.getInstance().decodeBoolean("isFirstOpen", true)){
//
CrashReport.initCrashReport(application, Constants.BUGLY_APP_ID, false);
//
}
return
null
;
}
...
...
library_base/src/main/java/com/fry/base/global/Constants.java
View file @
dc4c934e
package
com
.
fry
.
base
.
global
;
import
com.fry.base.utils.PropertyUtils
;
/**
* Created by jeme on 2019/9/17
*/
...
...
@@ -56,6 +54,8 @@ public class Constants {
}
public
static
String
getBaseUrl
()
{
return
PropertyUtils
.
getApiBaseUrl
();
//fry
// return PropertyUtils.getApiBaseUrl();
return
""
;
}
}
}
\ No newline at end of file
library_base/src/main/java/com/fry/base/global/InitConstants.java
View file @
dc4c934e
...
...
@@ -52,7 +52,9 @@ public class InitConstants {
public
static
int
getVersionCode
()
{
if
(
VERSION_CODE
==
null
)
{
return
BuildConfig
.
VERSION_CODE
;
//fry
//return BuildConfig.VERSION_CODE;
return
0
;
}
return
VERSION_CODE
;
}
...
...
@@ -66,6 +68,7 @@ public class InitConstants {
public
static
String
getVersionName
()
{
if
(
VERSION_NAME
==
null
)
{
return
BuildConfig
.
VERSION_NAME
;
return
""
;
}
return
VERSION_NAME
;
}
...
...
library_base/src/main/java/com/fry/base/netwrok/OkHttpInterceptor.kt
View file @
dc4c934e
This diff is collapsed.
Click to expand it.
library_base/src/main/java/com/fry/base/utils/BuildConfigUtils.java
deleted
100644 → 0
View file @
7c16a2b2
package
com
.
fry
.
base
.
utils
;
import
android.content.Context
;
import
androidx.annotation.StringDef
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.reflect.Field
;
/**
* 2019-10-18 created
*
* @author KOM
*/
public
class
BuildConfigUtils
{
/**
* 在build.gradle中配置字段的KEY
*/
@StringDef
({
ConfigField
.
DEBUG
,
ConfigField
.
APPLICATION_ID
,
ConfigField
.
BUILD_TYPE
,
ConfigField
.
FLAVOR
,
ConfigField
.
VERSION_CODE
,
ConfigField
.
VERSION_NAME
})
@Retention
(
RetentionPolicy
.
SOURCE
)
public
@interface
ConfigField
{
String
DEBUG
=
"DEBUG"
;
String
APPLICATION_ID
=
"APPLICATION_ID"
;
String
BUILD_TYPE
=
"BUILD_TYPE"
;
String
FLAVOR
=
"FLAVOR"
;
String
VERSION_CODE
=
"VERSION_CODE"
;
String
VERSION_NAME
=
"VERSION_NAME"
;
}
/**
* 获取APP模块下配置的 buildConfigField 的值
*/
public
static
<
T
>
T
getBuildConfigValue
(
Context
context
,
@ConfigField
String
fieldName
)
{
try
{
Class
<?>
clazz
=
Class
.
forName
(
context
.
getPackageName
()
+
".BuildConfig"
);
Field
field
=
clazz
.
getField
(
fieldName
);
return
(
T
)
field
.
get
(
null
);
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
NoSuchFieldException
e
)
{
e
.
printStackTrace
();
}
catch
(
IllegalAccessException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
library_base/src/main/java/com/fry/base/utils/PropertyKey.java
deleted
100644 → 0
View file @
7c16a2b2
package
com
.
fry
.
base
.
utils
;
import
androidx.annotation.StringDef
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
/**
* 2019-10-18 created
*
* @author KOM
*/
@StringDef
({
PropertyKey
.
BASE_URL
,
PropertyKey
.
IS_PRODUCT
})
@Retention
(
RetentionPolicy
.
SOURCE
)
public
@interface
PropertyKey
{
String
NAME
=
"name"
;
String
BASE_URL
=
"api.base.url"
;
String
IS_PRODUCT
=
"isProduct"
;
}
library_base/src/main/java/com/fry/base/utils/PropertyUtils.java
deleted
100644 → 0
View file @
7c16a2b2
package
com
.
fry
.
base
.
utils
;
import
android.content.Context
;
import
android.util.Log
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Properties
;
import
me.goldze.mvvmhabit.utils.Utils
;
/**
* 2019-10-18 created
*
* @author KOM
*/
public
class
PropertyUtils
{
private
static
Properties
mProps
=
new
Properties
();
private
static
boolean
mHasLoadProps
=
false
;
private
static
final
Object
mLock
=
new
Object
();
private
static
final
String
TAG
=
"PropertyUtils"
;
public
PropertyUtils
()
{
}
/**
* 初始化 级别应该最高
*/
public
static
void
init
(
Context
context
)
{
if
(!
mHasLoadProps
)
{
synchronized
(
mLock
)
{
if
(!
mHasLoadProps
)
{
try
{
ConfigManager
.
EnvironmentType
environmentType
=
ConfigManager
.
getDefault
().
getAppEnv
();
InputStream
is
=
context
.
getAssets
().
open
(
environmentType
.
configType
+
".properties"
);
mProps
.
load
(
is
);
mHasLoadProps
=
true
;
Log
.
d
(
"PropertyUtils"
,
"load config.properties successfully!"
);
}
catch
(
IOException
var4
)
{
Log
.
e
(
"PropertyUtils"
,
"load config.properties error!"
,
var4
);
}
}
}
}
}
public
static
String
getApiBaseUrl
()
{
if
(
mProps
==
null
)
{
throw
new
IllegalArgumentException
(
"must call #UtilsManager.init(context) in application"
);
}
else
{
return
mProps
.
getProperty
(
PropertyKey
.
BASE_URL
,
""
);
}
}
public
static
boolean
isProduct
()
{
return
mProps
.
getProperty
(
PropertyKey
.
IS_PRODUCT
,
"false"
).
equals
(
"true"
);
}
public
static
String
getEnvironmentName
()
{
return
mProps
.
getProperty
(
PropertyKey
.
NAME
,
""
);
}
public
static
ConfigManager
.
EnvironmentType
environmentMap
()
{
String
envName
=
getEnvironmentName
();
switch
(
envName
){
case
"product"
:
return
ConfigManager
.
EnvironmentType
.
PRODUCT
;
default
:
return
ConfigManager
.
EnvironmentType
.
TEST
;
}
}
public
static
boolean
isDebug
()
{
Boolean
isDebug
=
BuildConfigUtils
.
getBuildConfigValue
(
Utils
.
getContext
(),
BuildConfigUtils
.
ConfigField
.
DEBUG
);
return
isDebug
==
null
?
true
:
isDebug
;
}
public
static
String
getValueByKey
(
String
key
)
{
return
mProps
.
getProperty
(
key
,
""
);
}
}
library_base/src/main/java/com/fry/base/utils/encry/AESUtils.java
View file @
dc4c934e
package
com
.
fry
.
base
.
utils
.
encry
;
import
android.util.Log
;
import
javax.crypto.Cipher
;
import
javax.crypto.spec.IvParameterSpec
;
import
javax.crypto.spec.SecretKeySpec
;
import
Decoder.BASE64Decoder
;
import
Decoder.BASE64Encoder
;
public
class
AESUtils
{
private
static
final
String
vis
=
MD5
.
GetMD5Code
(
"goldcamera_2021"
).
substring
(
8
,
24
);
// public static final String key = "123456";
public
static
String
CIPHER_ALGORITHM
=
"AES/CBC/PKCS5Padding"
;
// optional value AES/DES/DESede
private
static
SecretKeySpec
getKey
(
String
strKey
)
throws
Exception
{
byte
[]
arrBTmp
=
strKey
.
getBytes
();
byte
[]
arrB
=
new
byte
[
16
];
// 创建一个空的16位字节数组(默认值为0)
for
(
int
i
=
0
;
i
<
arrBTmp
.
length
&&
i
<
arrB
.
length
;
i
++)
{
arrB
[
i
]
=
arrBTmp
[
i
];
}
SecretKeySpec
skeySpec
=
new
SecretKeySpec
(
arrB
,
"AES"
);
return
skeySpec
;
}
public
static
String
encrypt
(
String
message
,
String
key
)
{
try
{
SecretKeySpec
skeySpec
=
getKey
(
key
);
Cipher
cipher
=
Cipher
.
getInstance
(
CIPHER_ALGORITHM
);
IvParameterSpec
iv
=
new
IvParameterSpec
(
vis
.
getBytes
());
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
skeySpec
,
iv
);
byte
[]
encrypted
=
cipher
.
doFinal
(
message
.
getBytes
(
"UTF-8"
));
return
new
BASE64Encoder
().
encode
(
encrypted
);
}
catch
(
Exception
e
)
{
}
return
""
;
}
public
static
String
detrypt
(
String
message
,
String
key
)
{
try
{
byte
[]
res
=
new
BASE64Decoder
().
decodeBuffer
(
message
);
SecretKeySpec
skeySpec
=
getKey
(
key
);
Cipher
cipher
=
Cipher
.
getInstance
(
CIPHER_ALGORITHM
);
IvParameterSpec
iv
=
new
IvParameterSpec
(
vis
.
getBytes
());
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
skeySpec
,
iv
);
byte
[]
detrypted
=
cipher
.
doFinal
(
res
);
return
new
String
(
detrypted
,
"UTF-8"
);
}
catch
(
Exception
e
)
{
}
return
""
;
}
private
static
String
getBK1
()
{
return
BuildConfig
.
AppKeyPre
;
}
private
static
String
getBK2
()
{
return
"nnnnnn"
;
}
private
static
String
getBK3
(
int
size
)
{
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
1
;
i
<=
size
;
i
++)
{
sb
.
append
(
i
);
}
return
sb
.
toString
();
}
public
static
String
getDefaultKey
()
{
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
getBK1
())
.
append
(
getBK2
())
.
append
(
getBK3
(
6
));
return
sb
.
toString
();
}
}
package
com
.
fry
.
base
.
utils
.
encry
;
import
android.util.Log
;
import
com.fry.base.BuildConfig
;
import
javax.crypto.Cipher
;
import
javax.crypto.spec.IvParameterSpec
;
import
javax.crypto.spec.SecretKeySpec
;
import
Decoder.BASE64Decoder
;
import
Decoder.BASE64Encoder
;
public
class
AESUtils
{
private
static
final
String
vis
=
MD5
.
GetMD5Code
(
"goldcamera_2021"
).
substring
(
8
,
24
);
// public static final String key = "123456";
public
static
String
CIPHER_ALGORITHM
=
"AES/CBC/PKCS5Padding"
;
// optional value AES/DES/DESede
private
static
SecretKeySpec
getKey
(
String
strKey
)
throws
Exception
{
byte
[]
arrBTmp
=
strKey
.
getBytes
();
byte
[]
arrB
=
new
byte
[
16
];
// 创建一个空的16位字节数组(默认值为0)
for
(
int
i
=
0
;
i
<
arrBTmp
.
length
&&
i
<
arrB
.
length
;
i
++)
{
arrB
[
i
]
=
arrBTmp
[
i
];
}
SecretKeySpec
skeySpec
=
new
SecretKeySpec
(
arrB
,
"AES"
);
return
skeySpec
;
}
public
static
String
encrypt
(
String
message
,
String
key
)
{
try
{
SecretKeySpec
skeySpec
=
getKey
(
key
);
Cipher
cipher
=
Cipher
.
getInstance
(
CIPHER_ALGORITHM
);
IvParameterSpec
iv
=
new
IvParameterSpec
(
vis
.
getBytes
());
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
skeySpec
,
iv
);
byte
[]
encrypted
=
cipher
.
doFinal
(
message
.
getBytes
(
"UTF-8"
));
return
new
BASE64Encoder
().
encode
(
encrypted
);
}
catch
(
Exception
e
)
{
}
return
""
;
}
public
static
String
detrypt
(
String
message
,
String
key
)
{
try
{
byte
[]
res
=
new
BASE64Decoder
().
decodeBuffer
(
message
);
SecretKeySpec
skeySpec
=
getKey
(
key
);
Cipher
cipher
=
Cipher
.
getInstance
(
CIPHER_ALGORITHM
);
IvParameterSpec
iv
=
new
IvParameterSpec
(
vis
.
getBytes
());
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
skeySpec
,
iv
);
byte
[]
detrypted
=
cipher
.
doFinal
(
res
);
return
new
String
(
detrypted
,
"UTF-8"
);
}
catch
(
Exception
e
)
{
}
return
""
;
}
private
static
String
getBK1
()
{
return
BuildConfig
.
AppKeyPre
;
}
private
static
String
getBK2
()
{
return
"nnnnnn"
;
}
private
static
String
getBK3
(
int
size
)
{
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
1
;
i
<=
size
;
i
++)
{
sb
.
append
(
i
);
}
return
sb
.
toString
();
}
public
static
String
getDefaultKey
()
{
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
getBK1
())
.
append
(
getBK2
())
.
append
(
getBK3
(
6
));
return
sb
.
toString
();
}
}
library_base/version.properties
View file @
dc4c934e
#Wed Jun 30 1
7:38:32
CST 2021
VERSION_BUILD
=
2
228
#Wed Jun 30 1
9:52:15
CST 2021
VERSION_BUILD
=
2
320
mvvmhabit/build.gradle
View file @
dc4c934e
...
...
@@ -19,7 +19,9 @@ android {
}
dependencies
{
implementation
fileTree
(
include:
[
'*.jar'
,
'*.aar'
],
dir:
'libs'
)
//implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
provided
files
(
'libs\\xpopup-release.aar'
)
//support
api
rootProject
.
ext
.
support
[
"support-v4"
]
api
rootProject
.
ext
.
support
[
"appcompat-v7"
]
...
...
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