Skip to content

Commit a358447

Browse files
committed
see 08/26 log
1 parent db383b3 commit a358447

File tree

8 files changed

+64
-16
lines changed

8 files changed

+64
-16
lines changed

README-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.19.2-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.19.3-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

4747
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ If this project helps you a lot and you want to support the project's developmen
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.19.2-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.19.3-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

4747
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

app/src/main/java/com/blankj/androidutilcode/feature/core/app/AppActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ public void initView(Bundle savedInstanceState, View contentView) {
8686
.appendLine("getAppPath: " + AppUtils.getAppPath())
8787
.appendLine("getAppVersionName: " + AppUtils.getAppVersionName())
8888
.appendLine("getAppVersionCode: " + AppUtils.getAppVersionCode())
89-
.append("getAppSignatureSHA1: " + AppUtils.getAppSignatureSHA1())
89+
.appendLine("getAppSignatureSHA1: " + AppUtils.getAppSignatureSHA1())
90+
.appendLine("getAppSignatureSHA256: " + AppUtils.getAppSignatureSHA256())
91+
.append("getAppSignatureMD5: " + AppUtils.getAppSignatureMD5())
9092
.create());
9193
}
9294

config.gradle

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ ext {
66
compileSdkVersion: 27,
77
minSdkVersion : 14,
88
targetSdkVersion : 27,
9-
versionCode : 1_019_002,
10-
versionName : '1.19.2'// E.g 1.9.72 => 1,009,072
9+
versionCode : 1_019_003,
10+
versionName : '1.19.3'// E.g. 1.9.72 => 1,009,072
1111
]
1212

1313
versionConfig = [
@@ -19,6 +19,7 @@ ext {
1919
gson : '2.8.2',
2020
glide : '4.7.1',
2121
leakcanary : '1.5.4',
22+
retrofit : '2.4.0',
2223
// test
2324
junit : '4.12',
2425
robolectric: '3.1.2'
@@ -39,6 +40,7 @@ ext {
3940
],
4041
gson : "com.google.code.gson:gson:$versionConfig.gson",
4142
glide : "com.github.bumptech.glide:glide:$versionConfig.glide",
43+
retrofit : "com.squareup.retrofit2:retrofit:$versionConfig.retrofit",
4244

4345
junit : "junit:junit:$versionConfig.junit",
4446
robolectric : "org.robolectric:robolectric:$versionConfig.robolectric",
@@ -167,7 +169,7 @@ def configAppDependencies(Project pro) {
167169
// LeakCanary
168170
debugImplementation depConfig.leakcanary.android
169171
releaseImplementation depConfig.leakcanary.android_no_op
170-
// implementation 'com.blankj:utilcode:1.19.2'
172+
// implementation 'com.blankj:utilcode:1.19.3'
171173
}
172174
}
173175

@@ -191,6 +193,7 @@ def configSubUtilDependencies(Project pro) {
191193
api(depConfig.glide) {
192194
exclude group: "com.android.support"
193195
}
196+
api depConfig.retrofit
194197

195198
testImplementation depConfig.junit
196199
testImplementation depConfig.robolectric

update_log.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* 18/08/26 新增 AppUtils#getAppSignatureSHA256 和 AppUtils#getAppSignatureMD5,发布 1.19.3
12
* 18/08/24 新增 ScreenUtils#restoreAdaptScreen,利用 FileProvider4UtilCode 不再需要初始化,发布 1.19.2
23
* 18/08/23 修复适配后 ToastUtils 原生 Toast 尺寸发生改变的问题,修复 KeyboardUtils#fixSoftInputLeaks,发布 1.19.1
34
* 18/08/10 修复 ScreenUtils#adaptxx 导致获取状态栏和导航栏尺寸不对问题,发布 1.19.0

utilcode/README-CN.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.19.2'
5+
implementation 'com.blankj:utilcode:1.19.3'
66
```
77

88

@@ -51,6 +51,8 @@ getAppVersionName : 获取 App 版本号
5151
getAppVersionCode : 获取 App 版本码
5252
getAppSignature : 获取 App 签名
5353
getAppSignatureSHA1 : 获取应用签名的的 SHA1 值
54+
getAppSignatureSHA256 : 获取应用签名的的 SHA256 值
55+
getAppSignatureMD5 : 获取应用签名的的 MD5 值
5456
getAppInfo : 获取 App 信息
5557
getAppsInfo : 获取所有已安装 App 信息
5658
```

utilcode/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Gradle:
44
```groovy
5-
implementation 'com.blankj:utilcode:1.19.2'
5+
implementation 'com.blankj:utilcode:1.19.3'
66
```
77

88

@@ -51,6 +51,8 @@ getAppVersionName
5151
getAppVersionCode
5252
getAppSignature
5353
getAppSignatureSHA1
54+
getAppSignatureSHA256
55+
getAppSignatureMD5
5456
getAppInfo
5557
getAppsInfo
5658
```

utilcode/src/main/java/com/blankj/utilcode/util/AppUtils.java

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -650,11 +650,53 @@ public static String getAppSignatureSHA1() {
650650
* @return the application's signature for SHA1 value
651651
*/
652652
public static String getAppSignatureSHA1(final String packageName) {
653+
return getAppSignatureHash(packageName, "SHA1");
654+
}
655+
656+
/**
657+
* Return the application's signature for SHA256 value.
658+
*
659+
* @return the application's signature for SHA256 value
660+
*/
661+
public static String getAppSignatureSHA256() {
662+
return getAppSignatureSHA256(Utils.getApp().getPackageName());
663+
}
664+
665+
/**
666+
* Return the application's signature for SHA256 value.
667+
*
668+
* @param packageName The name of the package.
669+
* @return the application's signature for SHA256 value
670+
*/
671+
public static String getAppSignatureSHA256(final String packageName) {
672+
return getAppSignatureHash(packageName, "SHA256");
673+
}
674+
675+
/**
676+
* Return the application's signature for MD5 value.
677+
*
678+
* @return the application's signature for MD5 value
679+
*/
680+
public static String getAppSignatureMD5() {
681+
return getAppSignatureMD5(Utils.getApp().getPackageName());
682+
}
683+
684+
/**
685+
* Return the application's signature for MD5 value.
686+
*
687+
* @param packageName The name of the package.
688+
* @return the application's signature for MD5 value
689+
*/
690+
public static String getAppSignatureMD5(final String packageName) {
691+
return getAppSignatureHash(packageName, "MD5");
692+
}
693+
694+
private static String getAppSignatureHash(final String packageName, final String algorithm) {
653695
if (isSpace(packageName)) return "";
654696
Signature[] signature = getAppSignature(packageName);
655697
if (signature == null || signature.length <= 0) return "";
656-
return encryptSHA1ToString(signature[0].toByteArray()).
657-
replaceAll("(?<=[0-9A-F]{2})[0-9A-F]{2}", ":$0");
698+
return bytes2HexString(hashTemplate(signature[0].toByteArray(), algorithm))
699+
.replaceAll("(?<=[0-9A-F]{2})[0-9A-F]{2}", ":$0");
658700
}
659701

660702
/**
@@ -860,14 +902,10 @@ private static boolean isDeviceRooted() {
860902
private static final char HEX_DIGITS[] =
861903
{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
862904

863-
private static String encryptSHA1ToString(final byte[] data) {
864-
return bytes2HexString(encryptSHA1(data));
865-
}
866-
867-
private static byte[] encryptSHA1(final byte[] data) {
905+
private static byte[] hashTemplate(final byte[] data, final String algorithm) {
868906
if (data == null || data.length <= 0) return null;
869907
try {
870-
MessageDigest md = MessageDigest.getInstance("SHA1");
908+
MessageDigest md = MessageDigest.getInstance(algorithm);
871909
md.update(data);
872910
return md.digest();
873911
} catch (NoSuchAlgorithmException e) {

0 commit comments

Comments
 (0)